Home | History | Annotate | Line # | Download | only in llib
llib-lstdc revision 1.1
      1 /*
      2  * Copyright (c) 1994, 1995 Jochen Pohl
      3  * All Rights Reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *      This product includes software developed by Jochen Pohl for
     16  *	The NetBSD Project.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  *
     31  *	$Id: llib-lstdc,v 1.1 1995/07/03 20:56:39 cgd Exp $
     32  */
     33 
     34 /* LINTLIBRARY */
     35 
     36 #define _ANSI_SOURCE
     37 
     38 #include <assert.h>
     39 #include <ctype.h>
     40 #include <errno.h>
     41 #include <locale.h>
     42 #include <math.h>
     43 #include <setjmp.h>
     44 #include <signal.h>
     45 #include <stdarg.h>
     46 #include <stddef.h>
     47 #include <stdio.h>
     48 #include <stdlib.h>
     49 #include <string.h>
     50 #include <time.h>
     51 
     52 /* PROTOLIB1 */
     53 
     54 /*
     55  * assert.h
     56  */
     57 #ifdef __NetBSD__
     58 void	(__assert)(const char *expression, int line, const char *file);
     59 #else
     60 void	(assert)(int expression);
     61 #endif
     62 
     63 /*
     64  * ctype.h
     65  */
     66 int	(isalnum)(int c);
     67 int	(isalpha)(int c);
     68 int	(iscntrl)(int c);
     69 int	(isdigit)(int c);
     70 int	(isgraph)(int c);
     71 int	(islower)(int c);
     72 int	(isprint)(int c);
     73 int	(ispunct)(int c);
     74 int	(isspace)(int c);
     75 int	(isupper)(int c);
     76 int	(isxdigit)(int c);
     77 int	(tolower)(int c);
     78 int	(toupper)(int c);
     79 
     80 /*
     81  * errno.h
     82  */
     83 int	(errno);
     84 
     85 /*
     86  * locale.h
     87  */
     88 char *(setlocale)(int category, const char *locale);
     89 struct lconv *(localeconv)(void);
     90 
     91 /*
     92  * math.h
     93  */
     94 double	(acos)(double x);
     95 double	(asin)(double x);
     96 double	(atan)(double x);
     97 double	(atan2)(double y, double x);
     98 double	(cos)(double x);
     99 double	(sin)(double x);
    100 double	(tan)(double x);
    101 double	(cosh)(double x);
    102 double	(sinh)(double x);
    103 double	(tanh)(double x);
    104 double	(exp)(double x);
    105 double	(frexp)(double value, int *exp);
    106 double	(ldexp)(double x, int exp);
    107 double	(log)(double x);
    108 double	(log10)(double x);
    109 double	(modf)(double value, double *iptr);
    110 double	(pow)(double x, double y);
    111 double	(sqrt)(double x);
    112 double	(ceil)(double x);
    113 double	(fabs)(double x);
    114 double	(floor)(double x);
    115 double	(fmod)(double x, double y);
    116 
    117 /*
    118  * setjmp.h
    119  */
    120 int	(setjmp)(jmp_buf env);
    121 void	(longjmp)(jmp_buf env, int val);
    122 
    123 /*
    124  * signal.h
    125  */
    126 void	(*(signal)(int sig, void (*func)(int)))(int);
    127 int	(raise)(int sig);
    128 
    129 /*
    130  * stdio.h
    131  */
    132 int	(remove)(const char *filename);
    133 int	(rename)(const char *old, const char *new);
    134 FILE	*(tmpfile)(void);
    135 char	*(tmpnam)(char *s);
    136 int	(fclose)(FILE *stream);
    137 int	(fflush)(FILE *stream);
    138 FILE	*(fopen)(const char *filename, const char *mode);
    139 FILE	*(freopen)(const char *filename, const char *mode, FILE *stream);
    140 void	(setbuf)(FILE *stream, char *buf);
    141 int	(setvbuf)(FILE *stream, char *buf, int mode, size_t size);
    142 /* PRINTFLIKE2 */
    143 int	(fprintf)(FILE *stream, const char *format, ...);
    144 /* SCANFLIKE2 */
    145 int	(fscanf)(FILE *stream, const char *format, ...);
    146 /* PRINTFLIKE1 */
    147 int	(printf)(const char *format, ...);
    148 /* SCANFLIKE1 */
    149 int	(scanf)(const char *format, ...);
    150 /* PRINTFLIKE2 */
    151 int	(sprintf)(char *s, const char *format, ...);
    152 /* SCANFLIKE2 */
    153 int	(sscanf)(const char *s, const char *format, ...);
    154 int	(vfprintf)(FILE *stream, const char *format, va_list arg);
    155 int	(vprintf)(const char *format, va_list arg);
    156 int	(vsprintf)(char *s, const char *format, va_list arg);
    157 int	(fgetc)(FILE *stream);
    158 #ifdef __NetBSD__
    159 char	*(fgets)(char *s, size_t n, FILE *stream);
    160 #else
    161 char	*(fgets)(char *s, int n, FILE *stream);
    162 #endif
    163 int	(fputc)(int c, FILE *stream);
    164 int	(fputs)(const char *s, FILE *stream);
    165 int	(getc)(FILE *stream);
    166 int	(getchar)(void);
    167 char	*(gets)(char *s);
    168 int	(putc)(int c, FILE *stream);
    169 int	(putchar)(int c);
    170 int	(puts)(const char *s);
    171 int	(ungetc)(int c, FILE *stream);
    172 size_t	(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
    173 size_t	(fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
    174 int	(fgetpos)(FILE *stream, fpos_t *pos);
    175 int	(fseek)(FILE *stream, long offset, int whence);
    176 int	(fsetpos)(FILE *stream, const fpos_t *pos);
    177 #ifdef __NetBSD__
    178 long	(ftell)(const FILE *stream);
    179 #else
    180 long	(ftell)(FILE *stream);
    181 #endif
    182 void	(rewind)(FILE *stream);
    183 void	(clearerr)(FILE *stream);
    184 int	(feof)(FILE *stream);
    185 int	(ferror)(FILE *stream);
    186 void	(perror)(const char *s);
    187 
    188 /*
    189  * stdlib.h
    190  */
    191 double	(atof)(const char *nptr);
    192 int	(atoi)(const char *nptr);
    193 long	(atol)(const char *nptr);
    194 double	(strtod)(const char *nptr, char **endptr);
    195 long	(strtol)(const char *nptr, char **endptr, int base);
    196 unsigned long (strtoul)(const char *nptr, char **endptr, int base);
    197 int	(rand)(void);
    198 void	(srand)(unsigned seed);
    199 void	*(calloc)(size_t nmemb, size_t size);
    200 void	(free)(void *ptr);
    201 void	*(malloc)(size_t size);
    202 void	*(realloc)(void *ptr, size_t size);
    203 void	(abort)(void);
    204 int	(atexit)(void (*func)(void));
    205 void	(exit)(int status);
    206 char	*(getenv)(const char *name);
    207 int	(system)(const char *string);
    208 void	*(bsearch)(const void *key, const void *base, size_t nmemb,
    209 		   size_t size, int (*compar)(const void *, const void *));
    210 void	(qsort)(void *base, size_t nmemb, size_t size,
    211 		int (*compar)(const void *, const void *));
    212 int	(abs)(int j);
    213 div_t	(div)(int numer, int denom);
    214 long	(labs)(long j);
    215 ldiv_t	(ldiv)(long numer, long denom);
    216 int	(mblen)(const char *s, size_t n);
    217 int	(mbtowc)(wchar_t *PWC, const char *s, size_t n);
    218 int	(wctomb)(char *s, wchar_t wchar);
    219 size_t	(mbstowcs)(wchar_t *pwcs, const char *s, size_t n);
    220 size_t	(wcstombs)(char *s, const wchar_t *pwcs, size_t n);
    221 
    222 /*
    223  * string.h
    224  */
    225 void	*(memcpy)(void *s1, const void *s2, size_t n);
    226 void	*(memmove)(void *s1, const void *s2, size_t n);
    227 char	*(strcpy)(char *s1, const char *s2);
    228 char	*(strncpy)(char *s1, const char *s2, size_t n);
    229 char	*(strcat)(char *s1, const char *s2);
    230 char	*(strncat)(char *s1, const char *s2, size_t n);
    231 int	(memcmp)(const void *s1, const void *s2, size_t n);
    232 int	(strcmp)(const char *s1, const char *s2);
    233 int	(strcoll)(const char *s1, const char *s2);
    234 int	(strncmp)(const char *s1, const char *s2, size_t n);
    235 size_t	(strxfrm)(char *s1, const char *s2, size_t n);
    236 void	*(memchr)(const void *s, int c, size_t n);
    237 char	*(strchr)(const char *s, int c);
    238 size_t	(strcspn)(const char *s1, const char *s2);
    239 char	*(strpbrk)(const char *s1, const char *s2);
    240 char	*(strrchr)(const char *s1, int c);
    241 size_t	(strspn)(const char *s1, const char *s2);
    242 char	*(strstr)(const char *s1, const char *s2);
    243 char	*(strtok)(char *s1, const char *s2);
    244 void	*(memset)(void *s, int c, size_t n);
    245 char	*(strerror)(int errnom);
    246 size_t	(strlen)(const char *s);
    247 
    248 /*
    249  * time.h
    250  */
    251 clock_t (clock)(void);
    252 double	(difftime)(time_t time1, time_t time2);
    253 time_t	(mktime)(struct tm *timeptr);
    254 time_t	(time)(time_t *timer);
    255 char	*(asctime)(const struct tm *timeptr);
    256 char	*(ctime)(const time_t *timer);
    257 struct tm *(gmtime)(const time_t *timer);
    258 struct tm *(localtime)(const time_t *timer);
    259 size_t	(strftime)(char *s, size_t maxsize, const char *format,
    260 		   const struct tm *timeptr);
    261