diff -ruN -x CVS kos/Makefile kos.local/Makefile --- kos/Makefile Wed Sep 26 03:04:59 2001 +++ kos.local/Makefile Sat Dec 22 12:40:13 2001 @@ -11,7 +11,8 @@ -rm -f lib/* $(KOS_MAKE) -C utils clean $(KOS_MAKE) -C kernel clean - $(KOS_MAKE) -C examples clean + $(KOS_MAKE) -C addons clean + $(KOS_MAKE) -C examples clean build-utils: $(KOS_MAKE) -C utils diff -ruN -x CVS kos/Makefile.prefab kos.local/Makefile.prefab --- kos/Makefile.prefab Wed Sep 26 03:04:59 2001 +++ kos.local/Makefile.prefab Sat Dec 22 12:37:59 2001 @@ -18,7 +18,7 @@ -cp $(OBJS) $(KOS_BASE)/$(BUILD_TARGET)/build/ clean: clean_subdirs - -rm -f $(OBJS) *.bck + -rm -f $(OBJS) *.bck include $(KOS_BASE)/Makefile.rules diff -ruN -x CVS kos/Makefile.rules kos.local/Makefile.rules --- kos/Makefile.rules Wed Sep 26 03:04:59 2001 +++ kos.local/Makefile.rules Sat Dec 22 11:24:06 2001 @@ -14,6 +14,9 @@ %.o: %.cc $(KOS_CCPLUS) $(KOS_CFLAGS) $(KOS_LOCAL_CFLAGS) -D_arch_$(KOS_ARCH) $(KOS_CPPFLAGS) -I$(KOS_INCS) -I$(KOS_BASE)/kernel/arch/$(KOS_ARCH)/include -c $< -o $@ + +%.o: %.cpp + $(KOS_CCPLUS) $(KOS_CFLAGS) $(KOS_LOCAL_CFLAGS) -D_arch_$(KOS_ARCH) $(KOS_CPPFLAGS) -I$(KOS_INCS) -I$(KOS_BASE)/kernel/arch/$(KOS_ARCH)/include -c $< -o $@ %.o: %.s $(KOS_AS) $(KOS_AFLAGS) $< -o $@ diff -ruN -x CVS kos/addons/libdcutils/Makefile kos.local/addons/libdcutils/Makefile --- kos/addons/libdcutils/Makefile Wed Sep 26 03:05:10 2001 +++ kos.local/addons/libdcutils/Makefile Sat Dec 22 11:06:44 2001 @@ -5,7 +5,7 @@ # # $Id: Makefile,v 1.1.1.1 2001/09/26 07:05:10 bardtx Exp $ -OBJS = 3dutils.o bspline.o pcx.o precompiler.o pvrutils.o rand.o vmu.o matrix.o +OBJS = 3dutils.o bspline.o pcx.o precompiler.o pvrutils.o vmu.o matrix.o OBJS += pcx_texture.o SUBDIRS = diff -ruN -x CVS kos/addons/libdcutils/rand.c kos.local/addons/libdcutils/rand.c --- kos/addons/libdcutils/rand.c Sun Nov 4 01:16:47 2001 +++ kos.local/addons/libdcutils/rand.c Sat Dec 22 11:06:44 2001 @@ -8,16 +8,6 @@ static char id[] = "E3CD $Id: rand.c,v 1.2 2001/11/04 06:16:47 bardtx Exp $"; - -static unsigned long seed=123; -#define RNDC 1013904223 -#define RNDM 1164525 - -int rand() { - seed = seed * RNDM + RNDC; - return seed; -} - int randnum(int limit) { int shift, i; diff -ruN -x CVS kos/addons/libjpeg/Makefile kos.local/addons/libjpeg/Makefile --- kos/addons/libjpeg/Makefile Wed Sep 26 03:05:02 2001 +++ kos.local/addons/libjpeg/Makefile Sat Dec 22 11:06:44 2001 @@ -14,7 +14,7 @@ jidctflt.o jidctred.o jquant1.o \ jquant2.o jutils.o jmemmgr.o OBJS += jmemnobs.o -OBJS += kos_fake_func.o kos_texture.o +OBJS += kos_texture.o SUBDIRS = myall: $(OBJS) diff -ruN -x CVS kos/addons/libjpeg/jpeglib.h kos.local/addons/libjpeg/jpeglib.h --- kos/addons/libjpeg/jpeglib.h Wed Sep 26 03:05:05 2001 +++ kos.local/addons/libjpeg/jpeglib.h Sat Dec 22 11:06:44 2001 @@ -13,7 +13,7 @@ #ifndef JPEGLIB_H #define JPEGLIB_H -#include "kos_fake_func.h" +#include #include /* diff -ruN -x CVS kos/addons/libjpeg/kos_fake_func.c kos.local/addons/libjpeg/kos_fake_func.c --- kos/addons/libjpeg/kos_fake_func.c Wed Sep 26 03:05:03 2001 +++ kos.local/addons/libjpeg/kos_fake_func.c Wed Dec 31 19:00:00 1969 @@ -1,59 +0,0 @@ -#include - -typedef unsigned int FILE; - -FILE * fopen(const char *path, const char *mode) -{ - if (mode[0] == 'r') - return (FILE *)fs_open(path, O_RDONLY); - if (mode[0] == 'w') - return (FILE *)fs_open(path, O_WRONLY); - return 0; -} - -/* int fprintf(FILE *stream, const char *fmt, ...) -{ - va_list args; - int i; - char buf[1024]; - - if (stream <= 2) { - va_start(args, fmt); - i = vsprintf(buf, fmt, args); - va_end(args); - - printf("%s", buf); - - return i; - } else - return -1; -} */ - -int fclose(FILE *stream) -{ - fs_close((unsigned int)stream); - return 0; -} - -unsigned int fread(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream) -{ - return fs_read((unsigned int)stream, ptr, size*nmemb)/size; -} - -unsigned int fwrite(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream) -{ - return fs_write((unsigned int)stream, ptr, size*nmemb)/size; -} - -int fseek(FILE *stream, long offset, int whence) -{ - return fs_seek((unsigned int)stream, offset, whence); -} - -void exit(int status) -{ - printf("fake exit() called - you must reset now\n"); - while(1); -} - - diff -ruN -x CVS kos/addons/libjpeg/kos_fake_func.h kos.local/addons/libjpeg/kos_fake_func.h --- kos/addons/libjpeg/kos_fake_func.h Wed Sep 26 03:05:03 2001 +++ kos.local/addons/libjpeg/kos_fake_func.h Wed Dec 31 19:00:00 1969 @@ -1,19 +0,0 @@ -#ifndef __KOS_FAKE_FUNC__ -#define __KOS_FAKE_FUNC__ - -#define stderr 2 - -typedef unsigned int FILE; - -FILE * fopen(const char *path, const char *mode); -/* int fprintf(FILE *stream, const char *fmt, ...); */ -#define fprintf(stream, fmt, ARGS...) printf(fmt, ## ARGS) -int fclose(FILE *stream); -unsigned int fread(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream); -unsigned int fwrite(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream); -int fseek(FILE *stream, long offset, int whence); -int sprintf(char *buf, const char *fmt, ...) ; -void exit(int status); - -#endif - diff -ruN -x CVS kos/addons/libmp3/Makefile kos.local/addons/libmp3/Makefile --- kos/addons/libmp3/Makefile Wed Sep 26 03:05:07 2001 +++ kos.local/addons/libmp3/Makefile Sat Dec 22 12:36:29 2001 @@ -16,7 +16,7 @@ include $(KOS_BASE)/Makefile.prefab clean: clean_subdirs - rm -f build/* + rm -f build/*.o build/*.a run: diff -ruN -x CVS kos/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/kos_fake_func.h kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/kos_fake_func.h --- kos/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/kos_fake_func.h Mon Nov 12 01:03:39 2001 +++ kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/kos_fake_func.h Wed Dec 31 19:00:00 1969 @@ -1,19 +0,0 @@ -#ifndef __KOS_FAKE_FUNC__ -#define __KOS_FAKE_FUNC__ - -#define stderr 2 - -typedef unsigned int FILE; - -FILE * fopen(const char *path, const char *mode); -/* int fprintf(FILE *stream, const char *fmt, ...); */ -#define fprintf(stream, fmt, ARGS...) printf(fmt, ## ARGS) -int fclose(FILE *stream); -unsigned int fread(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream); -unsigned int fwrite(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream); -int fseek(FILE *stream, long offset, int whence); -int sprintf(char *buf, const char *fmt, ...) ; -void exit(int status); - -#endif - diff -ruN -x CVS kos/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/misc.h kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/misc.h --- kos/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/misc.h Mon Nov 12 01:03:39 2001 +++ kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/dc-files/misc.h Sat Dec 22 11:06:44 2001 @@ -18,7 +18,7 @@ #ifndef _V_RANDOM_H_ #define _V_RANDOM_H_ #include "vorbis/codec.h" -#include "kos_fake_func.h" +#include #include extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); diff -ruN -x CVS kos/addons/liboggvorbis/liboggvorbis/libvorbis/lib/analysis.c kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/lib/analysis.c --- kos/addons/liboggvorbis/liboggvorbis/libvorbis/lib/analysis.c Mon Nov 12 01:03:40 2001 +++ kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/lib/analysis.c Sat Dec 22 11:06:44 2001 @@ -24,7 +24,6 @@ #include "registry.h" #include "scales.h" #include "os.h" -#include "kos_fake_func.h" int analysis_noisy=1; diff -ruN -x CVS kos/addons/liboggvorbis/liboggvorbis/libvorbis/lib/kos_fake_func.h kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/lib/kos_fake_func.h --- kos/addons/liboggvorbis/liboggvorbis/libvorbis/lib/kos_fake_func.h Mon Nov 12 01:03:40 2001 +++ kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/lib/kos_fake_func.h Wed Dec 31 19:00:00 1969 @@ -1,19 +0,0 @@ -#ifndef __KOS_FAKE_FUNC__ -#define __KOS_FAKE_FUNC__ - -#define stderr 2 - -typedef unsigned int FILE; - -FILE * fopen(const char *path, const char *mode); -/* int fprintf(FILE *stream, const char *fmt, ...); */ -#define fprintf(stream, fmt, ARGS...) printf(fmt, ## ARGS) -int fclose(FILE *stream); -unsigned int fread(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream); -unsigned int fwrite(void *ptr, unsigned int size, unsigned int nmemb, FILE *stream); -int fseek(FILE *stream, long offset, int whence); -int sprintf(char *buf, const char *fmt, ...) ; -void exit(int status); - -#endif - diff -ruN -x CVS kos/addons/liboggvorbis/liboggvorbis/libvorbis/lib/misc.h kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/lib/misc.h --- kos/addons/liboggvorbis/liboggvorbis/libvorbis/lib/misc.h Mon Nov 12 01:03:40 2001 +++ kos.local/addons/liboggvorbis/liboggvorbis/libvorbis/lib/misc.h Sat Dec 22 11:06:44 2001 @@ -18,7 +18,7 @@ #ifndef _V_RANDOM_H_ #define _V_RANDOM_H_ #include "vorbis/codec.h" -#include "kos_fake_func.h" +#include #include extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); diff -ruN -x CVS kos/addons/liboggvorbis/liboggvorbisplay/sndvorbisfile.c kos.local/addons/liboggvorbis/liboggvorbisplay/sndvorbisfile.c --- kos/addons/liboggvorbis/liboggvorbisplay/sndvorbisfile.c Mon Nov 12 00:22:08 2001 +++ kos.local/addons/liboggvorbis/liboggvorbisplay/sndvorbisfile.c Sat Dec 22 11:14:10 2001 @@ -305,8 +305,10 @@ // first we have to try to get some data out of the current stream while((samples=vorbis_synthesis_pcmout(&vd,&pcm))>0) { - VorbisFile_sampletrack += samples; int j; + int bout; + int numberofbyte; + VorbisFile_sampletrack += samples; // int clipflag=0; // the "bout" variable holds the number of PCM samples we got. but this @@ -314,7 +316,7 @@ // // so to get the number of 16-bit samples we have to multiply by 2 // and to get the number of bytes at all we have to multiply by 4 - int bout=(samples0) { int j; + int numberofbyte; // int clipflag=0; // the "bout" variable holds the number of PCM samples we got. but this @@ -466,7 +469,7 @@ printf("liboggvorbis: clipping occured. continuing\n"); } */ - int numberofbyte= 4 * bout; + numberofbyte= 4 * bout; // See above why we have to use *2 !!! target+=(bout * 2); diff -ruN -x CVS kos/addons/libos/Makefile kos.local/addons/libos/Makefile --- kos/addons/libos/Makefile Wed Sep 26 03:05:01 2001 +++ kos.local/addons/libos/Makefile Sat Dec 22 12:38:59 2001 @@ -14,7 +14,7 @@ $(KOS_MAKE) -C process clean $(KOS_MAKE) -C main clean $(KOS_MAKE) -C userland clean - rm -f build/* + -rm -f build/*.o run: diff -ruN -x CVS kos/addons/libos/userland/Makefile kos.local/addons/libos/userland/Makefile --- kos/addons/libos/userland/Makefile Mon Oct 1 22:29:49 2001 +++ kos.local/addons/libos/userland/Makefile Sat Dec 22 12:40:24 2001 @@ -6,3 +6,4 @@ all: +clean: diff -ruN -x CVS kos/examples/dreamcast/ghettoplay-vorbis/songmenu.c kos.local/examples/dreamcast/ghettoplay-vorbis/songmenu.c --- kos/examples/dreamcast/ghettoplay-vorbis/songmenu.c Mon Nov 12 00:36:52 2001 +++ kos.local/examples/dreamcast/ghettoplay-vorbis/songmenu.c Sat Dec 22 11:15:29 2001 @@ -76,6 +76,7 @@ /* Draw all the song titles */ // for (i=0; i<14 && (top+i)= 0) { @@ -86,7 +87,6 @@ } /* Check for playlist entries */ - int li; for(li = 0; li #define GLU_FALSE 0 @@ -8,6 +12,10 @@ void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); + +#ifdef __cplusplus +} +#endif #endif /* __GL_GLU_H */ diff -ruN -x CVS kos/include/ctype.h kos.local/include/ctype.h --- kos/include/ctype.h Sun Nov 4 01:24:22 2001 +++ kos.local/include/ctype.h Sat Dec 22 11:30:02 2001 @@ -8,13 +8,61 @@ #ifndef __CTYPE_H #define __CTYPE_H + +#ifdef __cplusplus +extern "C" { +#endif -#define isprint(c) (((c) > ' ') && ((c) < '~')) -#define isascii(c) (((c) & ~0x7F) == 0) -#define islower(c) (((c) >= 'a' && (c) <= 'z')) -#define isupper(c) (((c) >= 'A' && (c) <= 'Z')) -#define isdigit(c) (((c) >= '0' && (c) <= '9')) -#define tolower(c) (isupper(c) ? ((c) + ('a' - 'A')) : (c)) -#define toupper(c) (islower(c) ? ((c) - ('a' - 'A')) : (c)) +/* Unix specification requires the definition of these as functions too */ +int isalpha(int); +int isupper(int); +int islower(int); +int isdigit(int); +int isxdigit(int); +int isspace(int); +int ispunct(int); +int isalnum(int); +int isblank(int); +int isprint(int); +int isgraph(int); +int iscntrl(int); +int isascii(int); +int toascii(int); +int tolower(int); +int toupper(int); + +#define _U 0x01 /* upper */ +#define _L 0x02 /* lower */ +#define _N 0x04 /* number */ +#define _S 0x08 /* space */ +#define _P 0x10 /* punct */ +#define _C 0x20 /* control */ +#define _X 0x40 /* hex number */ +#define _B 0x80 /* blank */ + +extern const char _ctype_[]; + +#define isalpha(c) (_ctype_[(unsigned)(c)] & (_U|_L)) +#define isupper(c) (_ctype_[(unsigned)(c)] & _U) +#define islower(c) (_ctype_[(unsigned)(c)] & _L) +#define isdigit(c) (_ctype_[(unsigned)(c)] & _N) +#define isxdigit(c) (_ctype_[(unsigned)(c)] & (_X|_N)) +#define isspace(c) (_ctype_[(unsigned)(c)] & _S) +#define ispunct(c) (_ctype_[(unsigned)(c)] & _P) +#define isalnum(c) (_ctype_[(unsigned)(c)] & (_U|_L|_N)) +#define isblank(c) (_ctype_[(unsigned)(c)] & _B) +#define isprint(c) (_ctype_[(unsigned)(c)] & (_P|_U|_L|_N|_B)) +#define isgraph(c) (_ctype_[(unsigned)(c)] & (_P|_U|_L|_N)) +#define iscntrl(c) (_ctype_[(unsigned)(c)] & _C) +#define isascii(c) (((c) & ~0x7F) == 0) +#define toascii(c) ((c) & 0x7f) +#define tolower(c) (isupper(c) ? ((c) + ('a' - 'A')) : (c)) +#define toupper(c) (islower(c) ? ((c) - ('a' - 'A')) : (c)) +#define _tolower(c) ((c) + ('a' - 'A')) +#define _toupper(c) ((c) - ('a' - 'A')) + +#ifdef __cplusplus +} +#endif #endif diff -ruN -x CVS kos/include/dcutils/3dutils.h kos.local/include/dcutils/3dutils.h --- kos/include/dcutils/3dutils.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/dcutils/3dutils.h Sat Dec 22 13:04:50 2001 @@ -9,6 +9,10 @@ #ifndef __3DUTILS_H #define __3DUTILS_H + +#if defined(__cplusplus) +extern "C" { +#endif #include @@ -31,6 +35,10 @@ void td_scale(float x, float y, float z); void td_project(); void td_transform_vectors(vector_t *vi, vector_t *vo, int veccnt, int skip); + +#if defined(__cplusplus) +} +#endif #endif /* __3DUTILS_H */ diff -ruN -x CVS kos/include/dcutils/bspline.h kos.local/include/dcutils/bspline.h --- kos/include/dcutils/bspline.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/dcutils/bspline.h Sat Dec 22 13:04:39 2001 @@ -6,6 +6,10 @@ #ifndef __BSPLINE_H #define __BSPLINE_H + +#if defined(__cplusplus) +extern "C" { +#endif /* Pass it an array of points and it will calculate a set of B-spline co-efficients for generating a curve. There must be at least one point @@ -18,5 +22,8 @@ values for the current set of coefficients. */ void bspline_get_point(float t, point_t *p); +#if defined(__cplusplus) +} +#endif #endif /* __BSPLINE_H */ diff -ruN -x CVS kos/include/dcutils/matrix.h kos.local/include/dcutils/matrix.h --- kos/include/dcutils/matrix.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/dcutils/matrix.h Sat Dec 22 13:04:26 2001 @@ -6,6 +6,10 @@ #ifndef __MATRIX_H #define __MATRIX_H + +#if defined(__cplusplus) +extern "C" { +#endif /* Matrix definition (4x4) */ typedef float matrix_t[4][4]; @@ -33,5 +37,8 @@ matrix. Each vector is three floats long. */ void mat_transform(vector_t *invecs, vector_t *outvecs, int veccnt, int vecskip); +#if defined(__cplusplus) +} +#endif #endif /* __MATRIX_H */ diff -ruN -x CVS kos/include/dcutils/pcx.h kos.local/include/dcutils/pcx.h --- kos/include/dcutils/pcx.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/dcutils/pcx.h Sat Dec 22 13:04:12 2001 @@ -9,6 +9,10 @@ #ifndef __PCX_H #define __PCX_H + +#if defined(__cplusplus) +extern "C" { +#endif #include @@ -25,6 +29,9 @@ int pcx_load_texture(const char *fn, int twiddle, int alpha, uint32 *txr, int *w, int *h); +#if defined(__cplusplus) +} +#endif #endif /* __PCX_H */ diff -ruN -x CVS kos/include/dcutils/precompiler.h kos.local/include/dcutils/precompiler.h --- kos/include/dcutils/precompiler.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/dcutils/precompiler.h Sat Dec 22 13:04:00 2001 @@ -9,7 +9,11 @@ #ifndef __PRECOMPILER_H #define __PRECOMPILER_H - + +#if defined(__cplusplus) +extern "C" { +#endif + /* Resets the precompiler for another scene/object */ void pc_reset(int size); @@ -28,5 +32,8 @@ /* Shutdown */ void pc_shutdown(); +#if defined(__cplusplus) +} +#endif #endif /* __PRECOMPILER_H */ diff -ruN -x CVS kos/include/dcutils/pvrutils.h kos.local/include/dcutils/pvrutils.h --- kos/include/dcutils/pvrutils.h Sun Nov 4 01:25:06 2001 +++ kos.local/include/dcutils/pvrutils.h Sat Dec 22 13:03:50 2001 @@ -7,6 +7,10 @@ #ifndef __PVRUTILS_H #define __PVRUTILS_H + +#if defined(__cplusplus) +extern "C" { +#endif #include @@ -50,5 +54,9 @@ /* Commits an entire blank frame. Assumes two lists active (opaque/translucent) */ void pvr_blank_frame(); + +#if defined(__cplusplus) +} +#endif #endif /* __PVRUTILS_H */ diff -ruN -x CVS kos/include/jpeg/jpeg.h kos.local/include/jpeg/jpeg.h --- kos/include/jpeg/jpeg.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/jpeg/jpeg.h Sat Dec 22 13:05:43 2001 @@ -8,9 +8,17 @@ #ifndef __JPEG_JPEG_H #define __JPEG_JPEG_H + +#if defined(__cplusplus) +extern "C" { +#endif /* Load a JPEG file into a texture; returns 0 for success, -1 for failure. */ int jpeg_to_texture(const char * filename, uint32 tex, int size, int scale); + +#if defined(__cplusplus) +} +#endif #endif /* __JPEG_JPEG_H */ diff -ruN -x CVS kos/include/kos/cond.h kos.local/include/kos/cond.h --- kos/include/kos/cond.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/cond.h Sat Dec 22 13:00:13 2001 @@ -9,6 +9,10 @@ #ifndef __KOS_COND_H #define __KOS_COND_H + +#if defined(__cplusplus) +extern "C" { +#endif #include #include @@ -49,6 +53,10 @@ /* Init / shutdown */ int cond_init(); void cond_shutdown(); + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_COND_H */ diff -ruN -x CVS kos/include/kos/fs.h kos.local/include/kos/fs.h --- kos/include/kos/fs.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/fs.h Sat Dec 22 13:00:01 2001 @@ -9,6 +9,10 @@ #ifndef __KOS_FS_H #define __KOS_FS_H + +#if defined(__cplusplus) +extern "C" { +#endif #include #include @@ -84,6 +88,10 @@ /* VFS init */ int fs_init(); void fs_shutdown(); + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_FS_H */ diff -ruN -x CVS kos/include/kos/fs_builtin.h kos.local/include/kos/fs_builtin.h --- kos/include/kos/fs_builtin.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/fs_builtin.h Sat Dec 22 12:59:44 2001 @@ -8,6 +8,10 @@ #ifndef __KOS_FS_BUILTIN_H #define __KOS_FS_BUILTIN_H + +#if defined(__cplusplus) +extern "C" { +#endif /* Definitions for the "built-in" file system */ @@ -36,6 +40,10 @@ /* Init func */ int fs_builtin_init(); int fs_builtin_shutdown(); + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_FS_BUILTIN_H */ diff -ruN -x CVS kos/include/kos/fs_romdisk.h kos.local/include/kos/fs_romdisk.h --- kos/include/kos/fs_romdisk.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/fs_romdisk.h Sat Dec 22 12:59:30 2001 @@ -8,6 +8,10 @@ #ifndef __KOS_FS_ROMDISK_H #define __KOS_FS_ROMDISK_H + +#if defined(__cplusplus) +extern "C" { +#endif #include #include @@ -30,5 +34,8 @@ int fs_romdisk_init(uint8 *image); int fs_romdisk_shutdown(); +#if defined(__cplusplus) +} +#endif #endif /* __KOS_FS_ROMDISK_H */ diff -ruN -x CVS kos/include/kos/msg.h kos.local/include/kos/msg.h --- kos/include/kos/msg.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/msg.h Sat Dec 22 12:59:05 2001 @@ -10,6 +10,10 @@ #ifndef __KOS_MSG_H #define __KOS_MSG_H +#if defined(__cplusplus) +extern "C" { +#endif + #include #include #include @@ -76,6 +80,10 @@ int msg_replyv(channel_t id, int retval, iovec_t *data, int iovcnt); #endif /* _KERNEL */ + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_MSG_H */ diff -ruN -x CVS kos/include/kos/pcx.h kos.local/include/kos/pcx.h --- kos/include/kos/pcx.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/pcx.h Sat Dec 22 12:58:50 2001 @@ -9,6 +9,10 @@ #ifndef __KOS_PCX_H #define __KOS_PCX_H + +#if defined(__cplusplus) +extern "C" { +#endif #include @@ -28,5 +32,9 @@ /* This last version is the larger memory version (for use on DC, etc) */ /* XXX insert definition */ + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_PCX_H */ diff -ruN -x CVS kos/include/kos/sem.h kos.local/include/kos/sem.h --- kos/include/kos/sem.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/sem.h Sat Dec 22 12:58:39 2001 @@ -9,6 +9,10 @@ #ifndef __KOS_SEM_H #define __KOS_SEM_H + +#if defined(__cplusplus) +extern "C" { +#endif #include #include @@ -53,6 +57,10 @@ /* Init / shutdown */ int sem_init(); void sem_shutdown(); + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_SEM_H */ diff -ruN -x CVS kos/include/kos/thread.h kos.local/include/kos/thread.h --- kos/include/kos/thread.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/kos/thread.h Sat Dec 22 12:58:23 2001 @@ -9,6 +9,10 @@ #ifndef __KOS_THREAD_H #define __KOS_THREAD_H + +#if defined(__cplusplus) +extern "C" { +#endif #include #include @@ -164,6 +168,10 @@ /* Shutdown */ void thd_shutdown(); + +#if defined(__cplusplus) +} +#endif #endif /* __KOS_THREAD_H */ diff -ruN -x CVS kos/include/mp3/sfxmgr.h kos.local/include/mp3/sfxmgr.h --- kos/include/mp3/sfxmgr.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/mp3/sfxmgr.h Sat Dec 22 13:07:05 2001 @@ -6,10 +6,17 @@ #ifndef __SFXMGR_H #define __SFXMGR_H + +#ifdef __cplusplus +extern "C" { +#endif int sfx_load(const char *fn); void sfx_play(int idx, int vol, int pan); void sfx_unload_all(); +#ifdef __cplusplus +} +#endif #endif /* __SFXMGR_H */ diff -ruN -x CVS kos/include/mp3/sndmp3.h kos.local/include/mp3/sndmp3.h --- kos/include/mp3/sndmp3.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/mp3/sndmp3.h Sat Dec 22 13:06:52 2001 @@ -1,5 +1,9 @@ #ifndef __SNDMP3_H #define __SNDMP3_H + +#ifdef __cplusplus +extern "C" { +#endif int sndmp3_init(const char *fn, int loop); @@ -9,5 +13,9 @@ /* Shut everything down */ void sndmp3_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __SNDMP3_H */ diff -ruN -x CVS kos/include/mp3/sndserver.h kos.local/include/mp3/sndserver.h --- kos/include/mp3/sndserver.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/mp3/sndserver.h Sat Dec 22 13:06:36 2001 @@ -1,5 +1,9 @@ #ifndef __SNDSERVER_H #define __SNDSERVER_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include @@ -15,6 +19,10 @@ /* Shuts down the MP3 server thread */ int mp3_quit(); + +#ifdef __cplusplus +} +#endif #endif /* __SNDSERVER_H */ diff -ruN -x CVS kos/include/mp3/sndstream.h kos.local/include/mp3/sndstream.h --- kos/include/mp3/sndstream.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/mp3/sndstream.h Sat Dec 22 13:06:20 2001 @@ -8,6 +8,10 @@ #ifndef __SNDSTREAM_H #define __SNDSTREAM_H + +#if defined(__cplusplus) +extern "C" { +#endif #include #include @@ -48,6 +52,10 @@ /* Set the volume on the streaming channels */ void stream_volume(int vol); + +#ifdef __cplusplus +} +#endif #endif /* __SNDSTREAM_H */ diff -ruN -x CVS kos/include/oggvorbis/sndoggvorbis.h kos.local/include/oggvorbis/sndoggvorbis.h --- kos/include/oggvorbis/sndoggvorbis.h Mon Nov 12 00:52:33 2001 +++ kos.local/include/oggvorbis/sndoggvorbis.h Sat Dec 22 13:08:25 2001 @@ -9,6 +9,13 @@ * last mod: $Id: sndoggvorbis.h,v 1.1 2001/11/12 05:52:33 bardtx Exp $ */ +#ifndef __SNDOGGVORBIS_H +#define __SNDOGGVORBIS_H + +#ifdef __cplusplus +extern "C" { +#endif + int sndoggvorbis_init(); int sndoggvorbis_start(char *filename,int loop); void sndoggvorbis_stop(); @@ -29,3 +36,10 @@ char *sndoggvorbis_getartist(); char *sndoggvorbis_gettitle(); char *sndoggvorbis_getgenre(); + +#if defined(__cplusplus) +} +#endif + +#endif /* __SNDOGGVORBIS_H */ + diff -ruN -x CVS kos/include/os/elf.h kos.local/include/os/elf.h --- kos/include/os/elf.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/os/elf.h Sat Dec 22 13:09:29 2001 @@ -9,6 +9,10 @@ #ifndef __OS_ELF_H #define __OS_ELF_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include @@ -139,6 +143,10 @@ /* Free a loaded ELF program */ void elf_free(elf_prog_t *prog); + +#ifdef __cplusplus +} +#endif #endif /* __OS_ELF_H */ diff -ruN -x CVS kos/include/os/process.h kos.local/include/os/process.h --- kos/include/os/process.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/os/process.h Sat Dec 22 13:09:18 2001 @@ -9,6 +9,10 @@ #ifndef __OS_PROCESS_H #define __OS_PROCESS_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include @@ -67,5 +71,9 @@ /* initialization and shutdown */ int ps_init(); int ps_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __KALLISTI_PROCESS_H */ diff -ruN -x CVS kos/include/os/svcmpx.h kos.local/include/os/svcmpx.h --- kos/include/os/svcmpx.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/os/svcmpx.h Sat Dec 22 13:09:10 2001 @@ -9,6 +9,10 @@ #ifndef __OS_SVCMPX_H #define __OS_SVCMPX_H + +#ifdef __cplusplus +extern "C" { +#endif /* Gets a current handler */ void *svcmpx_get_handler(const char *name); @@ -24,6 +28,10 @@ int svcmpx_init(); void svcmpx_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __OS_SVCMPX_H */ diff -ruN -x CVS kos/include/stdio.h kos.local/include/stdio.h --- kos/include/stdio.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/stdio.h Sat Dec 22 12:17:26 2001 @@ -10,18 +10,77 @@ #ifndef __STDIO_H #define __STDIO_H +#if defined(__cplusplus) +extern "C" { +#endif + #include #include +#include -/* vsprintf.c */ -int vsprintf(char *buf, const char *fmt, va_list args); -int sprintf(char * buf, const char *fmt, ...); - -/* printf.c */ -int printf(const char *fmt, ...); - -/* To make porting programs a bit easier.. WARNING: only works on GCC */ -#define fprintf(BLAGH, ARGS...) printf(ARGS) +/* ANSI style wrappers for some of the fileio functions */ +#ifndef EOF +#define EOF (-1) +#endif + +typedef struct _FILE_t FILE; +typedef off_t fpos_t; + +void clearerr(FILE *); +int fclose(FILE *); +FILE *fdopen(int, const char *); +int feof(FILE *); +int ferror(FILE *); +int fflush(FILE *); +int fgetc(FILE *); +int fgetpos(FILE *, fpos_t *); +char *fgets(char *, int, FILE *); +int fileno(FILE *); +FILE *fopen(const char *, const char *); +int fprintf(FILE *, const char *, ...); +int fputc(int, FILE *); +int fputs(const char *, FILE *); +size_t fread(void *, size_t, size_t, FILE *); +FILE *freopen(const char *, const char *, FILE *); +int fscanf(FILE *, const char *, ...); +int fseek(FILE *, long int, int); +int fseeko(FILE *, off_t, int); +int fsetpos(FILE *, const fpos_t *); +long int ftell(FILE *); +off_t ftello(FILE *); +size_t fwrite(const void *, size_t, size_t, FILE *); +int getc(FILE *); +int getchar(void); +char *gets(char *); +int getw(FILE *); +int pclose(FILE *); +void perror(const char *); +FILE *popen(const char *, const char *); +int printf(const char *, ...); +int putc(int, FILE *); +int putchar(int); +int puts(const char *); +int putw(int, FILE *); +int remove(const char *); +int rename(const char *, const char *); +void rewind(FILE *); +int scanf(const char *, ...); +void setbuf(FILE *, char *); +int setvbuf(FILE *, char *, int, size_t); +int snprintf(char *, size_t, const char *, ...); +int sprintf(char *, const char *, ...); +int sscanf(const char *, const char *, ...); +char *tempnam(const char *, const char *); +FILE *tmpfile(void); +char *tmpnam(char *); +int ungetc(int, FILE *); +int vfprintf(FILE *, const char *, va_list); +int vprintf(const char *, va_list); +int vsnprintf(char *, size_t, const char *, va_list); +int vsprintf(char *, const char *, va_list); + +/* To make porting programs a bit easier.. WARNING: only works on GCC */ +#define fprintf(BLAGH, ARGS...) printf(ARGS) /* Kernel debugging printf; all output sent to this is filtered through a kernel log level check before actually being printed. This way, you @@ -41,6 +100,10 @@ /* Set debug level */ void dbglog_set_level(int level); + +#if defined(__cplusplus) +} +#endif #endif /* __STDIO_H */ diff -ruN -x CVS kos/include/stdlib.h kos.local/include/stdlib.h --- kos/include/stdlib.h Mon Oct 15 02:33:13 2001 +++ kos.local/include/stdlib.h Sat Dec 22 11:35:45 2001 @@ -9,6 +9,10 @@ #ifndef __STDLIB_H #define __STDLIB_H + +#if defined(__cplusplus) +extern "C" { +#endif #include @@ -18,13 +22,59 @@ /* To make future porting efforts simpler */ #define __P(x) x -/* Absolute value functions */ -int abs(int src); -long labs(long src); - -/* qsort */ -void qsort(void * base, size_t nmemb, size_t size, - int (*cmp)(const void *, const void *)); +/* random number functions */ +#define RAND_MAX 0x7fffffff + +typedef struct +{ + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct +{ + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +void abort(void); +int abs(int); +int atexit(void (*)(void)); +double atof(const char *); +int atoi(const char *); +long atol(const char *); +void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +void *calloc(size_t, size_t); +div_t div(int, int); +void exit(int); +char *getenv(const char *); +long labs(long); +ldiv_t ldiv(long, long); +int mblen(const char *, size_t); +size_t mbstowcs(wchar_t *, const char *, size_t); +int mbtowc(wchar_t *, const char *, size_t); +char *mktemp(char *); +int mkstemp(char *); +int putenv(char *); +void qsort(void *, size_t, size_t, int (*)(const void *, + const void *)); +int rand(void); +int rand_r(unsigned int *); +long random(void); +void *realloc(void *, size_t); +char *realpath(const char *, char *); +void srand(unsigned int); +double strtod(const char *, char **); +long strtol(const char *, char **, int); +unsigned long strtoul(const char *, char **, int); +int system(const char *); +size_t wcstombs(char *, const wchar_t *, size_t); +int wctomb(char *, wchar_t); + +#if defined(__cplusplus) +} +#endif #endif /* __STDLIB_H */ diff -ruN -x CVS kos/include/string.h kos.local/include/string.h --- kos/include/string.h Sun Nov 4 01:37:07 2001 +++ kos.local/include/string.h Sat Dec 22 11:38:01 2001 @@ -16,33 +16,37 @@ #include -void bcopy(const void * src, void * dest, size_t count); -char * index(const char *p, int ch); -void * memchr(const void *s, uint8 c, size_t n); -int memcmp(const void * cs,const void * ct,size_t count); -void * memcpy(void * dest,const void *src,size_t count); -void * memmove(void * dest,const void *src,size_t count); -void * memset(void * s,int c,size_t count); -void * memscan(void * addr, int c, size_t size); -char * rindex(const char *p, int ch); -char * strcat(char * dest, const char * src); -char * strchr(const char * s, int c); -int strcmp(const char * cs,const char * ct); -char * strcpy(char * dest,const char *src); -char * strdup(const char * src); -int stricmp(const char *cs, const char *ct); -size_t strlen(const char * s); -char * strncat(char *dest, const char *src, size_t count); -char * strncpy(char * dest,const char *src, size_t count); -int strnicmp(const char *cs, const char *ct, int cnt); -int strncmp(const char * cs,const char * ct,size_t count); -size_t strnlen(const char * s, size_t count); -char * strpbrk(const char * cs,const char * ct); -char * strrchr(const char * s, int c); -char * strsep(char **stringp, const char *delim); -size_t strspn(const char *s, const char *accept); -char * strstr(const char * s1,const char * s2); -char * strtok(char * s,const char * ct); +void bcopy(const void * src, void * dest, size_t count); +char * index(const char *p, int ch); +void * memchr(const void *s, uint8 c, size_t n); +int memcmp(const void * cs,const void * ct,size_t count); +void * memcpy(void * dest,const void *src,size_t count); +void * memmove(void * dest,const void *src,size_t count); +void * memset(void * s,int c,size_t count); +void * memscan(void * addr, int c, size_t size); +char * rindex(const char *p, int ch); +char * strcat(char * dest, const char * src); +char * strchr(const char * s, int c); +int strcmp(const char * cs,const char * ct); +int strcoll(const char *s1, const char *s2); +char * strcpy(char * dest,const char *src); +size_t strcspn(const char *s1, const char *s2); +char * strdup(const char * src); +char * strerror(int errnum); +int stricmp(const char *cs, const char *ct); +size_t strlen(const char * s); +char * strncat(char *dest, const char *src, size_t count); +char * strncpy(char * dest,const char *src, size_t count); +int strnicmp(const char *cs, const char *ct, int cnt); +int strncmp(const char * cs,const char * ct,size_t count); +size_t strnlen(const char * s, size_t count); +char * strpbrk(const char * cs,const char * ct); +char * strrchr(const char * s, int c); +char * strsep(char **stringp, const char *delim); +size_t strspn(const char *s, const char *accept); +char * strstr(const char * s1,const char * s2); +char * strtok(char * s,const char * ct); +size_t strxfrm(char *s1, const char *s2, size_t n); void * memcpy4(void * dest,const void *src,size_t count); void * memset4(void * s,unsigned long c,size_t count); diff -ruN -x CVS kos/include/time.h kos.local/include/time.h --- kos/include/time.h Wed Dec 31 19:00:00 1969 +++ kos.local/include/time.h Sat Dec 22 11:39:12 2001 @@ -0,0 +1,29 @@ +/* KallistiOS ##version## + + time.h + (c)2000 Dan Potter + + $Id$ + +*/ + +#ifndef __TIME_H +#define __TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef uint32 time_t; + +time_t time(time_t *t); +double difftime(time_t time1, time_t time0); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIME_H */ + diff -ruN -x CVS kos/include/unistd.h kos.local/include/unistd.h --- kos/include/unistd.h Wed Sep 26 03:05:20 2001 +++ kos.local/include/unistd.h Sat Dec 22 11:39:36 2001 @@ -9,12 +9,22 @@ #ifndef __UNISTD_H #define __UNISTD_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include #define true (1) #define false (0) + +void usleep(unsigned long usec); + +#ifdef __cplusplus +} +#endif #endif /* __UNISTD_H */ diff -ruN -x CVS kos/include/wchar.h kos.local/include/wchar.h --- kos/include/wchar.h Wed Dec 31 19:00:00 1969 +++ kos.local/include/wchar.h Sat Dec 22 11:40:35 2001 @@ -0,0 +1,15 @@ +/* KallistiOS ##version## + + wchar.h + (c)2001 Dan Potter + + $Id: $ +*/ + +#ifndef __WCHAR_H +#define __WCHAR_H + +#define __need_wchar_t +#include + +#endif /* __WCHAR_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/arch.h kos.local/kernel/arch/dreamcast/include/arch/arch.h --- kos/kernel/arch/dreamcast/include/arch/arch.h Sun Nov 4 14:47:39 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/arch.h Sat Dec 22 13:12:51 2001 @@ -8,6 +8,10 @@ #ifndef __ARCH_ARCH_H #define __ARCH_ARCH_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -72,6 +76,10 @@ int hardware_init(); void hardware_shutdown(); void syscall_init(); + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_ARCH_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/cache.h kos.local/kernel/arch/dreamcast/include/arch/cache.h --- kos/kernel/arch/dreamcast/include/arch/cache.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/cache.h Sat Dec 22 13:12:42 2001 @@ -8,6 +8,10 @@ #ifndef __ARCH_CACHE_H #define __ARCH_CACHE_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -19,6 +23,10 @@ /* Flush a range of o-cache/d-cache, given a physical address range */ void dcache_flush_range(uint32 start, uint32 count); + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_CACHE_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/dbgio.h kos.local/kernel/arch/dreamcast/include/arch/dbgio.h --- kos/kernel/arch/dreamcast/include/arch/dbgio.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/dbgio.h Sat Dec 22 13:12:29 2001 @@ -9,6 +9,10 @@ #ifndef __ARCH_DBGIO_H #define __ARCH_DBGIO_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -51,6 +55,10 @@ /* Printf functionality */ int dbgio_printf(const char *fmt, ...); + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_DBGIO_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/irq.h kos.local/kernel/arch/dreamcast/include/arch/irq.h --- kos/kernel/arch/dreamcast/include/arch/irq.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/irq.h Sat Dec 22 13:12:18 2001 @@ -9,6 +9,10 @@ #ifndef __ARCH_IRQ_H #define __ARCH_IRQ_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -159,6 +163,10 @@ /* Shutdown */ void irq_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_IRQ_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/mmu.h kos.local/kernel/arch/dreamcast/include/arch/mmu.h --- kos/kernel/arch/dreamcast/include/arch/mmu.h Sun Nov 4 14:46:35 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/mmu.h Sat Dec 22 13:12:08 2001 @@ -8,6 +8,10 @@ #ifndef __ARCH_MMU_H #define __ARCH_MMU_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include @@ -151,6 +155,10 @@ /* Init / shutdown MMU */ int mmu_init(); void mmu_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_MMU_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/rtc.h kos.local/kernel/arch/dreamcast/include/arch/rtc.h --- kos/kernel/arch/dreamcast/include/arch/rtc.h Sat Oct 6 23:53:40 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/rtc.h Sat Dec 22 13:11:57 2001 @@ -9,6 +9,10 @@ #ifndef __ARCH_RTC_H #define __ARCH_RTC_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -18,6 +22,9 @@ /* Returns the date/time value as a UNIX epoch time stamp */ time_t rtc_unix_secs(); +#ifdef __cplusplus +} +#endif #endif /* __ARCH_RTC_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/spinlock.h kos.local/kernel/arch/dreamcast/include/arch/spinlock.h --- kos/kernel/arch/dreamcast/include/arch/spinlock.h Mon Oct 1 22:25:41 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/spinlock.h Sat Dec 22 13:11:42 2001 @@ -8,6 +8,10 @@ #ifndef __ARCH_SPINLOCK_H #define __ARCH_SPINLOCK_H + +#ifdef __cplusplus +extern "C" { +#endif /* Defines processor specific spinlocks */ @@ -68,6 +72,9 @@ } while (0) #endif /* _userland */ +#ifdef __cplusplus +} +#endif #endif /* __ARCH_SPINLOCK_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/syscall.h kos.local/kernel/arch/dreamcast/include/arch/syscall.h --- kos/kernel/arch/dreamcast/include/arch/syscall.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/syscall.h Sat Dec 22 13:11:32 2001 @@ -9,6 +9,10 @@ #ifndef __ARCH_SYSCALL_H #define __ARCH_SYSCALL_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include @@ -38,6 +42,10 @@ __asm__("mov %0,r3\n" \ "trapa #0\n" : : "r"(routine)) +#ifdef __cplusplus +} +#endif + #endif /* __ARCH_SYSCALL_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/timer.h kos.local/kernel/arch/dreamcast/include/arch/timer.h --- kos/kernel/arch/dreamcast/include/arch/timer.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/timer.h Sat Dec 22 13:11:17 2001 @@ -9,6 +9,10 @@ #ifndef __ARCH_TIMER_H #define __ARCH_TIMER_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -60,6 +64,10 @@ /* Shutdown */ void timer_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_TIMER_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/arch/types.h kos.local/kernel/arch/dreamcast/include/arch/types.h --- kos/kernel/arch/dreamcast/include/arch/types.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/arch/types.h Sat Dec 22 13:10:54 2001 @@ -8,6 +8,10 @@ #ifndef __ARCH_TYPES_H #define __ARCH_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -54,6 +58,10 @@ /* Thread and priority types */ typedef handle_t tid_t; typedef handle_t prio_t; + +#ifdef __cplusplus +} +#endif #endif /* __ARCH_TYPES_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/biosfont.h kos.local/kernel/arch/dreamcast/include/dc/biosfont.h --- kos/kernel/arch/dreamcast/include/dc/biosfont.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/biosfont.h Sat Dec 22 13:17:25 2001 @@ -9,12 +9,20 @@ #ifndef __DC_BIOSFONT_H #define __DC_BIOSFONT_H + +#ifdef __cplusplus +extern "C" { +#endif #include void *bfont_find_char(int ch); void bfont_draw(uint16 *buffer, int bufwidth, int opaque, int c); void bfont_draw_str(uint16 *buffer, int width, int opaque, char *str); + +#ifdef __cplusplus +} +#endif #endif /* __DC_BIOSFONT_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/cdrom.h kos.local/kernel/arch/dreamcast/include/dc/cdrom.h --- kos/kernel/arch/dreamcast/include/dc/cdrom.h Wed Sep 26 03:05:13 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/cdrom.h Sat Dec 22 13:17:41 2001 @@ -9,6 +9,10 @@ #ifndef __DC_CDROM_H #define __DC_CDROM_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -82,5 +86,8 @@ int cdrom_init(); void cdrom_shutdown(); +#ifdef __cplusplus +} +#endif #endif /* __DC_CDROM_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/controller.h kos.local/kernel/arch/dreamcast/include/dc/controller.h --- kos/kernel/arch/dreamcast/include/dc/controller.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/controller.h Sat Dec 22 13:17:05 2001 @@ -10,6 +10,10 @@ #ifndef __DC_CONTROLLER_H #define __DC_CONTROLLER_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -43,6 +47,10 @@ } cont_cond_t; int cont_get_cond(uint8 addr, cont_cond_t *cond); + +#ifdef __cplusplus +} +#endif #endif /* __DC_CONTROLLER_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/ethernet.h kos.local/kernel/arch/dreamcast/include/dc/ethernet.h --- kos/kernel/arch/dreamcast/include/dc/ethernet.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/ethernet.h Sat Dec 22 13:17:59 2001 @@ -9,6 +9,10 @@ #ifndef __DC_ETHERNET_H #define __DC_ETHERNET_H + +#ifdef __cplusplus +extern "C" { +#endif /* RTL8139C register definitions */ #define RT_IDR0 0x00 /* Mac address */ @@ -101,6 +105,10 @@ /* Shutdown */ int eth_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __DC_ETHERNET_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/fmath.h kos.local/kernel/arch/dreamcast/include/dc/fmath.h --- kos/kernel/arch/dreamcast/include/dc/fmath.h Wed Sep 26 03:50:02 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/fmath.h Sat Dec 22 13:18:20 2001 @@ -9,6 +9,10 @@ #ifndef __DC_FMATH_H #define __DC_FMATH_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -139,6 +143,10 @@ extern inline float frsqrt(float f) { return __frsqrt(f); } + +#ifdef __cplusplus +} +#endif #endif /* __DC_FMATH_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/fs_dcload.h kos.local/kernel/arch/dreamcast/include/dc/fs_dcload.h --- kos/kernel/arch/dreamcast/include/dc/fs_dcload.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/fs_dcload.h Sat Dec 22 13:18:34 2001 @@ -7,6 +7,10 @@ #ifndef __DC_FS_DCLOAD_H #define __DC_FS_DCLOAD_H + +#ifdef __cplusplus +extern "C" { +#endif /* Definitions for the "dcload" file system */ @@ -100,6 +104,10 @@ void fs_dcload_init_console(); int fs_dcload_init(); int fs_dcload_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __KALLISTI_FS_DCLOAD_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/fs_iso9660.h kos.local/kernel/arch/dreamcast/include/dc/fs_iso9660.h --- kos/kernel/arch/dreamcast/include/dc/fs_iso9660.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/fs_iso9660.h Sat Dec 22 13:18:48 2001 @@ -8,6 +8,10 @@ #ifndef __DC_FS_ISO9660_H #define __DC_FS_ISO9660_H + +#ifdef __cplusplus +extern "C" { +#endif #include #include @@ -29,5 +33,8 @@ int fs_iso9660_init(); int fs_iso9660_shutdown(); +#ifdef __cplusplus +} +#endif #endif /* __DC_FS_ISO9660_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/fs_vmu.h kos.local/kernel/arch/dreamcast/include/dc/fs_vmu.h --- kos/kernel/arch/dreamcast/include/dc/fs_vmu.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/fs_vmu.h Sat Dec 22 12:52:11 2001 @@ -9,6 +9,10 @@ #ifndef __DC_FS_VMU_H #define __DC_FS_VMU_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -21,5 +25,9 @@ /* Initialization */ int fs_vmu_init(); int fs_vmu_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __DC_FS_VMU_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/g2.h kos.local/kernel/arch/dreamcast/include/dc/g2.h --- kos/kernel/arch/dreamcast/include/dc/g2.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/g2.h Sat Dec 22 12:51:58 2001 @@ -9,6 +9,10 @@ #ifndef __DC_G2_H #define __DC_G2_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -78,6 +82,10 @@ /* Shutdown */ void g2_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __DC_G2_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/keyboard.h kos.local/kernel/arch/dreamcast/include/dc/keyboard.h --- kos/kernel/arch/dreamcast/include/dc/keyboard.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/keyboard.h Sat Dec 22 12:51:43 2001 @@ -8,6 +8,10 @@ #ifndef __DC_KEYBOARD_H #define __DC_KEYBOARD_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -164,6 +168,10 @@ fairly periodically if you're expecting keyboard input. */ int kbd_poll(uint8 addr); + +#ifdef __cplusplus +} +#endif #endif /* __DC_KEYBOARD_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/maple.h kos.local/kernel/arch/dreamcast/include/dc/maple.h --- kos/kernel/arch/dreamcast/include/dc/maple.h Sun Oct 7 00:21:27 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/maple.h Sat Dec 22 12:51:29 2001 @@ -10,6 +10,10 @@ #ifndef __DC_MAPLE_H #define __DC_MAPLE_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -108,5 +112,8 @@ /* First VMU */ uint8 maple_first_vmu(); +#ifdef __cplusplus +} +#endif #endif /* __DC_MAPLE_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/mouse.h kos.local/kernel/arch/dreamcast/include/dc/mouse.h --- kos/kernel/arch/dreamcast/include/dc/mouse.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/mouse.h Sat Dec 22 12:51:13 2001 @@ -9,6 +9,10 @@ #ifndef __DC_MOUSE_H #define __DC_MOUSE_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -32,6 +36,10 @@ } mouse_cond_t; int mouse_get_cond(uint8 addr, mouse_cond_t *cond); + +#ifdef __cplusplus +} +#endif #endif /* __DC_MOUSE_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/spu.h kos.local/kernel/arch/dreamcast/include/dc/spu.h --- kos/kernel/arch/dreamcast/include/dc/spu.h Sun Nov 4 01:33:00 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/spu.h Sat Dec 22 12:51:01 2001 @@ -9,6 +9,10 @@ #ifndef __DC_SPU_H #define __DC_SPU_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -45,5 +49,9 @@ /* These two are seperate because they have to be done at a different time */ int spu_dma_init(); void spu_dma_shutdown(); + +#ifdef __cplusplus +} +#endif #endif /* __DC_SPU_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/sq.h kos.local/kernel/arch/dreamcast/include/dc/sq.h --- kos/kernel/arch/dreamcast/include/dc/sq.h Wed Sep 26 03:38:31 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/sq.h Sat Dec 22 12:50:35 2001 @@ -9,6 +9,10 @@ #ifndef __DC_SQ_H #define __DC_SQ_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -29,6 +33,10 @@ /* fills n bytes at s with int c, s must be 32-byte aligned */ void * sq_set32(void *s, uint32 c, int n); + +#ifdef __cplusplus +} +#endif #endif diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/ta.h kos.local/kernel/arch/dreamcast/include/dc/ta.h --- kos/kernel/arch/dreamcast/include/dc/ta.h Sun Nov 4 01:27:35 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/ta.h Sat Dec 22 12:50:16 2001 @@ -8,6 +8,10 @@ #ifndef __DC_TA_H #define __DC_TA_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -251,6 +255,8 @@ : "r0") - +#ifdef __cplusplus +} +#endif #endif /* __DC_TA_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/video.h kos.local/kernel/arch/dreamcast/include/dc/video.h --- kos/kernel/arch/dreamcast/include/dc/video.h Mon Oct 15 00:06:50 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/video.h Sat Dec 22 12:49:54 2001 @@ -8,6 +8,10 @@ #ifndef __DC_VIDEO_H #define __DC_VIDEO_H + +#ifdef __cplusplus +extern "C" { +#endif #include @@ -95,6 +99,10 @@ void vid_shutdown(); //----------------------------------------------------------------------------- + +#ifdef __cplusplus +} +#endif #endif // __DC_VIDEO_H diff -ruN -x CVS kos/kernel/arch/dreamcast/include/dc/vmu.h kos.local/kernel/arch/dreamcast/include/dc/vmu.h --- kos/kernel/arch/dreamcast/include/dc/vmu.h Wed Sep 26 03:05:12 2001 +++ kos.local/kernel/arch/dreamcast/include/dc/vmu.h Sat Dec 22 12:49:33 2001 @@ -9,12 +9,20 @@ #ifndef __DC_VMU_H #define __DC_VMU_H + +#ifdef __cplusplus +extern "C" { +#endif #include int vmu_draw_lcd(uint8 addr, void *bitmap); int vmu_block_read(uint8 addr, uint16 blocknum, uint8 *buffer); int vmu_block_write(uint8 addr, uint16 blocknum, uint8 *buffer); + +#ifdef __cplusplus +} +#endif #endif /* __DC_VMU_H */ diff -ruN -x CVS kos/kernel/arch/dreamcast/kernel/banner.c kos.local/kernel/arch/dreamcast/kernel/banner.c --- kos/kernel/arch/dreamcast/kernel/banner.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/arch/dreamcast/kernel/banner.c Sat Dec 22 11:09:27 2001 @@ -0,0 +1,4 @@ +char banner[] = +"KallistiOS ##version##: Sat Dec 22 11:09:27 2001\n" +" Fulg@:/home/fulg/dc/kos/kos\n" +; diff -ruN -x CVS kos/kernel/fs/Makefile kos.local/kernel/fs/Makefile --- kos/kernel/fs/Makefile Wed Sep 26 03:05:10 2001 +++ kos.local/kernel/fs/Makefile Sat Dec 22 11:06:44 2001 @@ -5,7 +5,7 @@ # # $Id: Makefile,v 1.1.1.1 2001/09/26 07:05:10 bardtx Exp $ -OBJS = fs.o fs_builtin.o fs_romdisk.o +OBJS = fs.o fs_ansi.o fs_builtin.o fs_romdisk.o SUBDIRS = include $(KOS_BASE)/Makefile.prefab diff -ruN -x CVS kos/kernel/fs/fs_ansi.c kos.local/kernel/fs/fs_ansi.c --- kos/kernel/fs/fs_ansi.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/fs/fs_ansi.c Sat Dec 22 12:10:07 2001 @@ -0,0 +1,378 @@ +/* KallistiOS ##version## + + fs_ansi.c + (c)2000-2001 Tobias Gloth + +*/ + +static char id[] = "KOS $Id$"; + +#include + +#define MAX_FILE 16 + +typedef struct _FILE_t { + file_t file; + uint8 used; + uint8 owner; + uint8 error; + uint8 eof; + uint8 putback; + uint8 has_putback; +} _FILE_t; + +#include +#include +#include + +static FILE f[MAX_FILE]; +static int f_used = 0; + +/* Thread mutex */ +static spinlock_t mutex; + +#define VALID_FILE(X) (((X) >= &f[0]) && ((X) < &f[MAX_FILE]) && ((X)->used)) + +static FILE *alloc_file() { + FILE *result = 0; + spinlock_lock(&mutex); + if (f_used <= MAX_FILE) { + int i; + for (i=0; iused = 0; + f_used--; + } + spinlock_unlock(&mutex); +} + +static int convert_mode(const char *mode) { + + /* try to parse it corrrectly */ + int mode_r = 0, mode_a = 0, mode_w = 0, mode_b = 0, mode_p = 0; + + if (mode == (char *)0) { + return -1; + } + if (*mode == 'r') { + mode_r=1; + } else if (*mode == 'w') { + mode_w=1; + } else if (*mode == 'a') { + mode_w=1; + } else { + return -1; + } + mode++; + if (*mode == 'b') { + mode_b = 1; + mode++; + } + if (*mode == '+') { + mode_p = 1; + mode++; + } + if ((*mode == 'b') && (mode_b == 0)) { + mode_b = 1; + mode++; + } else if (*mode != '\0') { + return -1; + } + + if (mode_r && !mode_p) { + return O_RDONLY; + } else if (mode_r && mode_p) { + return O_RDWR; + } else if (mode_w && !mode_p) { + return O_WRONLY; + } else if (mode_w && mode_p) { + return O_RDWR; + } else if (mode_a && !mode_p) { + return O_APPEND; + } else if (mode_a && mode_p) { + return O_APPEND; + } + + return -1; +} + +FILE *fopen(const char *path, const char *mode) { + + file_t file; + int fsMode; + FILE *result; + + fsMode = convert_mode (mode); + if (fsMode == -1) { + return (FILE *)0; + } + result = alloc_file(); + if (!result) { + return (FILE *)0; + } + + file = fs_open (path, fsMode); + if (file == 0) { + release_file(result); + return (FILE *)0; + } + + result->file = file; + + return result; +} + +FILE *fdopen(int file, const char *mode) { + + FILE *result; + + if (file == 0) { + return (FILE *)0; + } + result = alloc_file(); + if (!result) { + return (FILE *)0; + } + + result->file = file; + result->owner = 0; + + return result; +} + +FILE *freopen(const char *path, const char *mode, FILE *file) { + + int fsMode; + + if (VALID_FILE(file)) { + if (file->owner) { + fs_close(file->file); + } + } + + fsMode = convert_mode (mode); + if (fsMode == -1) { + if (VALID_FILE(file)) { + release_file(file); + } + return (FILE *)0; + } + + if (!VALID_FILE(file)) { + file = alloc_file(); + } + if (!VALID_FILE(file)) { + return (FILE *)0; + } + + file->file = fs_open (path, fsMode); + if (file->file == 0) { + release_file(file); + return (FILE *)0; + } + + file->owner = 1; + file->eof = 0; + file->error = 0; + return file; +} + +int fclose(FILE *file) { + if (!VALID_FILE(file)) { + return EOF; + } + if (file->owner) { + fs_close(file->file); + } + release_file (file); + return 0; +} + +size_t fread(void *ptr, size_t size, size_t nmemb, FILE *file) { + size_t result = 0, to_read = size * nmemb; + if (!VALID_FILE(file) || (to_read == 0)) { + return 0; + } + if (file->has_putback) { + unsigned char *tmp = (unsigned char *)ptr; + *tmp = file->putback; + ptr = tmp+1; + file->has_putback = 0; + result++; + to_read--; + } + result += fs_read(file->file, ptr, to_read); + result = result / size; + if (result < 0) { + file->error = 1; + return 0; + } + if (result < size) { + file->eof = 1; + } + return result; +} + +int fgetc(FILE *file) { + unsigned char ch; + if (!fread(&ch, 1, 1, file)) { + return EOF; + } + return (int)ch; +} + +int ungetc(int c, FILE *file) { + if (!VALID_FILE(file) || (file->has_putback) || + (fs_tell(file->file) <= 0)) { + return EOF; + } + file->putback = c; + file->has_putback = 1; + return c; +} + +char *fgets(char *s, int size, FILE *file) { + + int i, ch; + + if (!VALID_FILE(file) || !s) { + return (char *)0; + } + for (i=0; ihas_putback) { + fs_seek(file->file, -1, SEEK_CUR); + file->has_putback = 0; + } + return fs_write(file->file, ptr, size*nmemb)/size; +} + +int puts(const char *str) { + size_t size = str ? strlen(str) : 0; + size_t written = printf ("%s\n", str); + return (written == size+1) ? 0 : EOF; +} + +int fputs(const char *s, FILE *file) { + + int len; + + if (!VALID_FILE(file) || !s) { + return -1; + } + len = strlen(s); + if ((fs_write(file->file, s, len) != len) || + (fs_write(file->file, "\n", 1) != 1)) { + return -1; + } + return 0; +} + +int fflush(FILE *file) { + if (!VALID_FILE(file)) { + return -1; + } + /* I think everything is flushed anyway */ + return 0; +} + +int fseek(FILE *file, long offset, int whence) { + if (!VALID_FILE(file)) { + return -1; + } + file->has_putback = 0; + return fs_seek(file->file, offset, whence) == -1 ? -1 : 0; +} + +long ftell(FILE *file) { + if (!VALID_FILE(file)) { + return -1; + } + return (long)fs_tell(file->file) - (file->has_putback ? 1 : 0); +} + +void rewind(FILE *file) { + fseek(file, 0, SEEK_SET); +} + +int fgetpos(FILE *file, fpos_t *pos) { + if (!pos || !VALID_FILE(file)) { + return -1; + } + *pos = fs_tell(file->file) - (file->has_putback ? 1 : 0); + return (*pos == -1) ? -1 : 0; +} + +int fsetpos(FILE *file, const fpos_t *pos) { + if (!pos || !VALID_FILE(file)) { + return -1; + } + file->has_putback = 0; + return fs_seek(file->file, *pos, SEEK_SET) == -1 ? -1 : 0; +} + +void clearerr(FILE *file) { + if (!VALID_FILE(file)) { + return; + } + file->error = 0; + file->eof = 0; +} + +int ferror(FILE *file) { + if (!VALID_FILE(file)) { + return -1; + } + return (int)file->error; +} + +int feof(FILE *file) { + if (!VALID_FILE(file)) { + return -1; + } + return (int)file->eof; +} + +int fileno(FILE *file) { + if (!VALID_FILE(file)) { + return 0; + } + return file->file; +} + diff -ruN -x CVS kos/kernel/libc/Makefile kos.local/kernel/libc/Makefile --- kos/kernel/libc/Makefile Sun Nov 4 05:31:51 2001 +++ kos.local/kernel/libc/Makefile Sat Dec 22 11:43:10 2001 @@ -14,7 +14,9 @@ OBJS += index.o rindex.o OBJS += strsep.o dtoa.o atoi.o OBJS += memset2.o memcpy2.o -OBJS += abort.o +OBJS += abort.o exit.o +OBJS += rand.o getenv.o usleep.o time.o +OBJS += ctype.o strcspn.o SUBDIRS = include $(KOS_BASE)/Makefile.prefab diff -ruN -x CVS kos/kernel/libc/ctype.c kos.local/kernel/libc/ctype.c --- kos/kernel/libc/ctype.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/ctype.c Sat Dec 22 12:00:14 2001 @@ -0,0 +1,153 @@ +/* Derived from Berkeley's ctype. Original license follows: */ +/* + * Copyright (c) 1989 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. + */ + +#include + +#undef isalpha +#undef isupper +#undef islower +#undef isdigit +#undef isxdigit +#undef isspace +#undef ispunct +#undef isalnum +#undef isblank +#undef isprint +#undef isgraph +#undef iscntrl +#undef isascii +#undef toascii +#undef tolower +#undef toupper + +/* hardcoded POSIX locale... */ +const char _ctype_[256] = { + _C, _C, _C, _C, _C, _C, _C, _C, /* 00-07 */ + _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, /* 08-0f */ + _C, _C, _C, _C, _C, _C, _C, _C, /* 10-17 */ + _C, _C, _C, _C, _C, _C, _C, _C, /* 18-1f */ + _S|_B, _P, _P, _P, _P, _P, _P, _P, /* 20-27 */ + _P, _P, _P, _P, _P, _P, _P, _P, /* 28-2f */ + _N, _N, _N, _N, _N, _N, _N, _N, /* 30-37 */ + _N, _N, _P, _P, _P, _P, _P, _P, /* 38-3f */ + _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, /* 40-47 */ + _U, _U, _U, _U, _U, _U, _U, _U, /* 48-4f */ + _U, _U, _U, _U, _U, _U, _U, _U, /* 50-57 */ + _U, _U, _U, _P, _P, _P, _P, _P, /* 58-5f */ + _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, /* 60-67 */ + _L, _L, _L, _L, _L, _L, _L, _L, /* 68-6f */ + _L, _L, _L, _L, _L, _L, _L, _L, /* 70-77 */ + _L, _L, _L, _P, _P, _P, _P, _C /* 78-7f */ + /* 80-ff */ +}; + +int isalpha(int c) +{ + return (_ctype_[c] & (_U|_L)); +} + +int isupper(int c) +{ + return (_ctype_[c] & _U); +} + +int islower(int c) +{ + return (_ctype_[c] & _L); +} + +int isdigit(int c) +{ + return (_ctype_[c] & _N); +} + +int isxdigit(int c) +{ + return (_ctype_[c] & (_X|_N)); +} + +int isspace(int c) +{ + return (_ctype_[c] & _S); +} + +int ispunct(int c) +{ + return (_ctype_[c] & _P); +} + +int isalnum(int c) +{ + return (_ctype_[c] & (_U|_L|_N)); +} + +int isblank(int c) +{ + return (_ctype_[c] & _B); +} + +int isprint(int c) +{ + return (_ctype_[c] & (_P|_U|_L|_N|_B)); +} + +int isgraph(int c) +{ + return (_ctype_[c] & (_P|_U|_L|_N)); +} + +int iscntrl(int c) +{ + return (_ctype_[c] & _C); +} + +int isascii(int c) +{ + return ((c & ~0x7F) == 0); +} + +int toascii(int c) +{ + return (c & 0x7f); +} + +int tolower(int c) +{ + return (isupper(c) ? (c + ('a' - 'A')) : c); +} + +int toupper(int c) +{ + return (islower(c) ? (c - ('a' - 'A')) : c); +} diff -ruN -x CVS kos/kernel/libc/exit.c kos.local/kernel/libc/exit.c --- kos/kernel/libc/exit.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/exit.c Sat Dec 22 11:06:44 2001 @@ -0,0 +1,15 @@ +/* KallistiOS ##version## + + exit.c + (c)2001 Dan Potter + + $Id$ +*/ + +#include + +/* exit() */ +void exit() { + arch_exit(); +} + diff -ruN -x CVS kos/kernel/libc/getenv.c kos.local/kernel/libc/getenv.c --- kos/kernel/libc/getenv.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/getenv.c Sat Dec 22 11:06:44 2001 @@ -0,0 +1,13 @@ +/* KallistiOS ##version## + + getenv.c + (c)2001 Dan Potter + + $Id$ +*/ + +/* getenv() */ +char *getenv(const char *name) { + return (char *)0; +} + diff -ruN -x CVS kos/kernel/libc/rand.c kos.local/kernel/libc/rand.c --- kos/kernel/libc/rand.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/rand.c Sat Dec 22 11:06:44 2001 @@ -0,0 +1,25 @@ +/* E3 Demo CD + + rand.c + (c)2000-2001 Dan Potter + + Optimal random number function +*/ + +static char id[] = "$Id$"; + +#include + +static unsigned long seed=123; +#define RNDC 1013904223 +#define RNDM 1164525 + +void srand(unsigned int s) { + seed = s; +} + +int rand() { + seed = seed * RNDM + RNDC; + return seed & RAND_MAX; +} + diff -ruN -x CVS kos/kernel/libc/strcspn.c kos.local/kernel/libc/strcspn.c --- kos/kernel/libc/strcspn.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/strcspn.c Sat Dec 22 12:01:47 2001 @@ -0,0 +1,75 @@ +/* + * This module was ported from the BSD 4.0 libc by Benoit Miller. Please + * see "README.BSD" in "docs" for more information. + * + * $Id: $ + */ + +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcspn.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include + +/* + * Span the complement of string s2. + */ +size_t +strcspn(s1, s2) + const char *s1; + const char *s2; +{ + const char *p, *spanp; + char c, sc; + + /* + * Stop as soon as we find any character from s2. Note that there + * must be a NUL in s2; it suffices to stop when we find that, too. + */ + for (p = s1;;) { + c = *p++; + spanp = s2; + do { + if ((sc = *spanp++) == c) + return (p - 1 - s1); + } while (sc != 0); + } + /* NOTREACHED */ +} + diff -ruN -x CVS kos/kernel/libc/time.c kos.local/kernel/libc/time.c --- kos/kernel/libc/time.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/time.c Sat Dec 22 11:06:44 2001 @@ -0,0 +1,25 @@ +/* KallistiOS ##version## + + time.c + (c)2001 Dan Potter + + $Id$ +*/ + +#include +#include + +/* time() */ +time_t time(time_t *ptr) { + time_t t = timer_count(TMU0) * 100; + if (ptr) { + *ptr = t; + } + return t; +} + +/* time() */ +double difftime(time_t time1, time_t time0) { + return (double)(time1 - time0); +} + diff -ruN -x CVS kos/kernel/libc/usleep.c kos.local/kernel/libc/usleep.c --- kos/kernel/libc/usleep.c Wed Dec 31 19:00:00 1969 +++ kos.local/kernel/libc/usleep.c Sat Dec 22 11:06:44 2001 @@ -0,0 +1,15 @@ +/* KallistiOS ##version## + + usleep.c + (c)2001 Dan Potter + + $Id$ +*/ + +#include + +/* usleep() */ +void usleep(unsigned long usec) { + timer_spin_sleep (usec / 1000); +} +