Index: branches/blackosx/i386/include/klibc/compiler.h =================================================================== --- branches/blackosx/i386/include/klibc/compiler.h (revision 0) +++ branches/blackosx/i386/include/klibc/compiler.h (revision 1748) @@ -0,0 +1,158 @@ +/* + * klibc/compiler.h + * + * Various compiler features + */ + +#ifndef _KLIBC_COMPILER_H +#define _KLIBC_COMPILER_H + +/* Specific calling conventions */ +/* __cdecl is used when we want varadic and non-varadic functions to have + the same binary calling convention. */ +#ifdef __i386__ +# ifdef __GNUC__ +# define __cdecl __attribute__((cdecl,regparm(0))) +# else + /* Most other C compilers have __cdecl as a keyword */ +# endif +#else +# define __cdecl /* Meaningless on non-i386 */ +#endif + +/* + * How to declare a function which should be inlined or instantiated locally + */ +#ifdef __GNUC__ +# ifdef __GNUC_STDC_INLINE__ +# define __static_inline static __inline__ __attribute__((__gnu_inline__)) +# else +# define __static_inline static __inline__ +# endif +#else +# define __static_inline inline /* Just hope this works... */ +#endif + +/* + * How to declare a function which should be inlined or have a call to + * an external module + */ +#ifdef __GNUC__ +# ifdef __GNUC_STDC_INLINE__ +# define __extern_inline extern __inline__ __attribute__((__gnu_inline__)) +# else +# define __extern_inline extern __inline__ +# endif +#else +# define __extern_inline inline /* Just hope this works... */ +#endif + +/* How to declare a function that *must* be inlined */ +/* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */ +#ifdef __GNUC__ +# if __GNUC__ >= 3 +# define __must_inline __extern_inline __attribute__((__always_inline__)) +# else +# define __must_inline extern __inline__ +# endif +#else +# define __must_inline inline /* Just hope this works... */ +#endif + +/* How to declare a function that does not return */ +#ifdef __GNUC__ +# define __noreturn void __attribute__((noreturn)) +#else +# define __noreturn void +#endif + +/* "const" function: + + Many functions do not examine any values except their arguments, + and have no effects except the return value. Basically this is + just slightly more strict class than the `pure' attribute above, + since function is not allowed to read global memory. + + Note that a function that has pointer arguments and examines the + data pointed to must _not_ be declared `const'. Likewise, a + function that calls a non-`const' function usually must not be + `const'. It does not make sense for a `const' function to return + `void'. +*/ +#ifdef __GNUC__ +# define __constfunc __attribute__((const)) +#else +# define __constfunc +#endif +#undef __attribute_const__ +#define __attribute_const__ __constfunc + +/* "pure" function: + + Many functions have no effects except the return value and their + return value depends only on the parameters and/or global + variables. Such a function can be subject to common subexpression + elimination and loop optimization just as an arithmetic operator + would be. These functions should be declared with the attribute + `pure'. +*/ +#ifdef __GNUC__ +# define __purefunc __attribute__((pure)) +#else +# define __purefunc +#endif +#undef __attribute_pure__ +#define __attribute_pure__ __purefunc + +/* Format attribute */ +#ifdef __GNUC__ +# define __formatfunc(t,f,a) __attribute__((format(t,f,a))) +#else +# define __formatfunc(t,f,a) +#endif + +/* malloc() function (returns unaliased pointer) */ +#if defined(__GNUC__) && (__GNUC__ >= 3) +# define __mallocfunc __attribute__((malloc)) +#else +# define __mallocfunc +#endif + +/* likely/unlikely */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) +# define __likely(x) __builtin_expect(!!(x), 1) +# define __unlikely(x) __builtin_expect(!!(x), 0) +#else +# define __likely(x) (!!(x)) +# define __unlikely(x) (!!(x)) +#endif + +/* Possibly unused function */ +#ifdef __GNUC__ +# define __unusedfunc __attribute__((unused)) +#else +# define __unusedfunc +#endif + +/* It's all user space... */ +#define __user + +/* The bitwise attribute: disallow arithmetric operations */ +#ifdef __CHECKER__ /* sparse only */ +# define __bitwise __attribute__((bitwise)) +#else +# define __bitwise +#endif + +/* Shut up unused warnings */ +#ifdef __GNUC__ +# define __attribute_used__ __attribute__((used)) +#else +# define __attribute_used__ +#endif + +/* Compiler pragma to make an alias symbol */ +#define __ALIAS(__t, __f, __p, __a) \ + __t __f __p __attribute__((weak, alias(#__a))); + +#endif Index: branches/blackosx/i386/klibc/strlcpy.c =================================================================== --- branches/blackosx/i386/klibc/strlcpy.c (revision 0) +++ branches/blackosx/i386/klibc/strlcpy.c (revision 1748) @@ -0,0 +1,27 @@ +/* + * strlcpy.c + */ + +#include +#include + +size_t strlcpy(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while ((ch = *p++)) { + if (bytes + 1 < size) + *q++ = ch; + + bytes++; + } + + /* If size == 0 there is no space for a final null... */ + if (size) + *q = '\0'; + + return bytes; +} Index: branches/blackosx/i386/klibc/LICENSE =================================================================== --- branches/blackosx/i386/klibc/LICENSE (revision 0) +++ branches/blackosx/i386/klibc/LICENSE (revision 1748) @@ -0,0 +1,73 @@ +This license applies to all files in directory and its subdirectories, +unless otherwise noted in individual files. + + +Some files are derived from files derived from the include/ directory +of the Linux kernel, and are licensed under the terms of the GNU +General Public License, version 2, as released by the Free Software +Foundation, Inc.; incorporated herein by reference. + + ----- + +Some files are derived from files copyrighted by the Regents of The +University of California, and are available under the following +license: + +Note: The advertising clause in the license appearing on BSD Unix +files was officially rescinded by the Director of the Office of +Technology Licensing of the University of California on July 22 +1999. He states that clause 3 is "hereby deleted in its entirety." + + * Copyright (c) + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + + ----- + +For all remaining files, the following license applies: + + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * Any copyright notice(s) and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Index: branches/blackosx/i386/klibc/Makefile =================================================================== --- branches/blackosx/i386/klibc/Makefile (revision 0) +++ branches/blackosx/i386/klibc/Makefile (revision 1748) @@ -0,0 +1,51 @@ +SRCROOT = $(abspath $(CURDIR)/../..) +OBJROOT = $(SRCROOT)/obj/i386/klibc +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot + +DIR = klibc +include ${SRCROOT}/Make.rules + +# LIBSAIODIR = ../libsaio + +CFLAGS := $(CFLAGS) $(RC_CFLAGS) $(MORECPP) -arch i386 \ + -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ + -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ + -march=pentium4 -msse2 -mfpmath=sse -msoft-float \ + -nostdinc -include $(SRCROOT)/autoconf.h + +CPPFLAGS := $(CPPFLAGS) -nostdinc++ + +INC = -I. -I$(SYMROOT) -I${SRCROOT}/i386/include + +OBJS = strlcpy.o + +OBJS := $(addprefix $(OBJROOT)/, $(OBJS)) + +LIBS = libklibc.a +LIBS := $(addprefix $(SYMROOT)/, $(LIBS)) + +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) + +all embedtheme: $(DIRS_NEEDED) $(LIBS) + + +$(LIBS): $(OBJS) + @echo "\t[RM] $@" + @rm -f $@ + @echo "\t[AR] $(@F)" + @ar q $@ $^ &> /dev/null + @echo "\t[RANLIB] $(@F)" + @ranlib $@ + +# dependencies +-include $(OBJROOT)/Makedep + +clean-local: + @for o in $(OBJS); do if [ -f "$${o}" ];then echo "\t[RM] $${o}"; fi; done + @for l in $(LIBS); do if [ -f "$${l}" ];then echo "\t[RM] $${l}"; fi; done + @rm -f $(LIBS) $(OBJS) Index: branches/blackosx/i386/boot2/Makefile =================================================================== --- branches/blackosx/i386/boot2/Makefile (revision 1747) +++ branches/blackosx/i386/boot2/Makefile (revision 1748) @@ -35,8 +35,8 @@ THEMEDIR = ../../artwork/themes/$(THEME) INC = -I. -I$(SRCROOT) -I$(SYMDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I${SRCROOT}/i386/include -LIBS= -L$(SYMDIR) -lsaio -lsa -LIBDEP= libsaio.a libsa.a +LIBS= -L$(SYMDIR) -lsaio -lsa -lklibc +LIBDEP= libsaio.a libsa.a libklibc.a OTHER_FILES = Index: branches/blackosx/i386/libsa/string.c =================================================================== --- branches/blackosx/i386/libsa/string.c (revision 1747) +++ branches/blackosx/i386/libsa/string.c (revision 1748) @@ -165,15 +165,6 @@ return ret; } -size_t -strlcpy(char * s1, const char * s2, size_t n) -{ - while (n && (*s1++ = *s2++)) - n--; - if (!n) *--s1=0; - return strlen(s2); -} - char * strstr(const char *in, const char *str) { Index: branches/blackosx/i386/Makefile =================================================================== --- branches/blackosx/i386/Makefile (revision 1747) +++ branches/blackosx/i386/Makefile (revision 1748) @@ -16,7 +16,7 @@ # The order of building is important. SUBDIRS_PRE = util -SUBDIRS = $(SUBDIRS_PRE) libsa libsaio boot0 boot1 boot2 cdboot modules +SUBDIRS = $(SUBDIRS_PRE) klibc libsa libsaio boot0 boot1 boot2 cdboot modules modules-builtin: @cd modules; ${MAKE} BUILT_IN=yes Index: branches/blackosx/Make.rules =================================================================== --- branches/blackosx/Make.rules (revision 1747) +++ branches/blackosx/Make.rules (revision 1748) @@ -141,13 +141,24 @@ || eval $$failcom; \ done + clean-dep: @if [ -f "$(OBJROOT)/Makedep" ];then echo "\t[RM] $(OBJROOT)/Makedep"; fi @rm -f $(OBJROOT)/Makedep + +FIND_IGNORE := \( -name .git -o -name .svn \) -prune -o -name Cconfig -o + +# clean: remove most generated files clean: clean-recursive clean-dep distclean: distclean-recursive clean-local clean-dep + @find . $(FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -size 0 \ + -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ + -type f -print | xargs rm -f clean-local: Index: branches/blackosx/Makefile =================================================================== --- branches/blackosx/Makefile (revision 1747) +++ branches/blackosx/Makefile (revision 1748) @@ -99,11 +99,15 @@ @gzip --best ${DISTFILE}.tar @mv ${DISTFILE}.tar.gz ${DISTFILE}.tgz -clean-local: clean-pkg-local +clean-local: + @if [ -d "$(SYMROOT)/package" ];then echo "\t[RMDIR] $(SYMROOT)/package"; fi @if [ -f "$(HEADER_VERSION)" ];then echo "\t[RM] $(HEADER_VERSION)"; fi @if [ -f "$(SRCROOT)/revision" ];then echo "\t[RM] $(SRCROOT)/revision"; fi - @rm -f $(HEADER_VERSION) $(SRCROOT)/revision + @rm -rf "$(SYMROOT)/package" $(HEADER_VERSION) $(SRCROOT)/revision +AUTOCONF_FILES = $(SRCROOT)/auto.conf $(SRCROOT)/autoconf.h \ + $(SRCROOT)/autoconf.inc $(SRCROOT)/.config $(SRCROOT)/.config.old + distclean-local: @if [ -d "$(OBJROOT)" ];then echo "\t[RMDIR] $(OBJROOT)"; fi @if [ -d "$(SYMROOT)" ];then echo "\t[RMDIR] $(SYMROOT)"; fi @@ -111,25 +115,33 @@ @if [ -d "$(SRCROOT)/i386/modules/module_includes" ];then \ echo "\t[RMDIR] $(SRCROOT)/i386/modules/module_includes"; \ fi - @if [ -f "$(SRCROOT)/auto.conf" ];then echo "\t[RM] $(SRCROOT)/auto.conf"; fi - @if [ -f "$(SRCROOT)/autoconf.h" ];then echo "\t[RM] $(SRCROOT)/autoconf.h"; fi - @if [ -f "$(SRCROOT)/autoconf.inc" ];then echo "\t[RM] $(SRCROOT)/autoconf.inc"; fi - + @for cfg in $(AUTOCONF_FILES); do if [ -f "$${cfg}" ];then echo "\t[RM] $${cfg}"; fi; done @rm -rf $(OBJROOT) $(SYMROOT) $(DSTROOT) \ $(SRCROOT)/i386/modules/module_includes \ - $(SRCROOT)/auto.conf \ - $(SRCROOT)/autoconf.h \ - $(SRCROOT)/autoconf.inc + $(AUTOCONF_FILES) pkg installer: all ${SRCROOT}/package/buildpkg.sh ${SYMROOT}/package -clean-pkg-local: - @if [ -d "$(SYMROOT)/package" ];then echo "\t[RMDIR] $(SYMROOT)/package"; fi - @rm -rf "$(SYMROOT)/package" +help: + @echo 'Configuration target:' + @echo ' config - Show configuration menu' + @echo + @echo 'Build targets:' + @echo ' all - Build all targets [DEFAULT]' + @echo ' dist - Build distribution tarball' + @echo ' pkg - Build installer package' + @echo + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files' + @echo ' distclean - Remove all generated files + config' +#@echo +# @echo 'Build options:' +# @echo 'make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' .PHONY: config .PHONY: clean .PHONY: image .PHONY: pkg .PHONY: installer +.PHONY: help Property changes on: branches/blackosx ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r1744-1747