remove __THROW

master
leitner 23 years ago
parent b600e2ef32
commit 3683655654

@ -3,8 +3,9 @@ all: t byte.a fmt.a scan.a str.a uint.a open.a stralloc.a unix.a socket.a buffer
VPATH=str:byte:fmt:scan:uint:open:stralloc:unix:socket:buffer:mmap
CC=gcc
CFLAGS=-I. -pipe -Wall -O2 -pipe -fomit-frame-pointer
#CFLAGS=-I. -pipe -Wall -Os -march=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
CFLAGS=-I. -I../dietlibc/include -pipe -Wall -Os -malign-functions=2 -fschedule-insns2 -g
#CFLAGS=-I. -I../dietlibc/include -pipe -Wall -Os -malign-functions=2 -fschedule-insns2 -g
#CFLAGS=-I../dietlibc/include -I. -pipe -Wall -Os -march=pentiumpro -mcpu=athlon -fomit-frame-pointer -fschedule-insns2 -Wall
#CFLAGS=-I../dietlibc/include -pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall

@ -6,35 +6,32 @@
#ifndef __pure__
#define __pure__
#endif
#ifndef __THROW
#define __THROW
#endif
/* byte_chr returns the smallest integer i between 0 and len-1
* inclusive such that one[i] equals needle, or len it not found. */
unsigned int byte_chr(const void* haystack, unsigned int len, char needle) __THROW __pure__;
unsigned int byte_chr(const void* haystack, unsigned int len, char needle) __pure__;
/* byte_rchr returns the largest integer i between 0 and len-1 inclusive
* such that one[i] equals needle, or len if not found. */
unsigned int byte_rchr(const void* haystack,unsigned int len,char needle) __THROW __pure__;
unsigned int byte_rchr(const void* haystack,unsigned int len,char needle) __pure__;
/* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
* to out[len-1]. */
void byte_copy(void* out, unsigned int len, const void* in) __THROW;
void byte_copy(void* out, unsigned int len, const void* in);
/* byte_copyr copies in[len-1] to out[len-1], in[len-2] to out[len-2],
* ... and in[0] to out[0] */
void byte_copyr(void* out, unsigned int len, const void* in) __THROW;
void byte_copyr(void* out, unsigned int len, const void* in);
/* byte_diff returns negative, 0, or positive, depending on whether the
* string a[0], a[1], ..., a[len-1] is lexicographically smaller
* than, equal to, or greater than the string b[0], b[1], ...,
* b[len-1]. When the strings are different, byte_diff does not read
* bytes past the first difference. */
int byte_diff(const void* a, unsigned int len, const void* b) __THROW __pure__;
int byte_diff(const void* a, unsigned int len, const void* b) __pure__;
/* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
void byte_zero(void* out, unsigned len) __THROW;
void byte_zero(void* out, unsigned len);
#define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))

24
fmt.h

@ -13,19 +13,19 @@
/* convert signed src integer -23 to ASCII '-','2','3', return length.
* If dest is not NULL, write result to dest */
unsigned int fmt_long(char *dest,signed long src) __THROW;
unsigned int fmt_long(char *dest,signed long src);
/* convert unsigned src integer 23 to ASCII '2','3', return length.
* If dest is not NULL, write result to dest */
unsigned int fmt_ulong(char *dest,unsigned long src) __THROW;
unsigned int fmt_ulong(char *dest,unsigned long src);
/* convert unsigned src integer 0x23 to ASCII '2','3', return length.
* If dest is not NULL, write result to dest */
unsigned int fmt_xlong(char *dest,unsigned long src) __THROW;
unsigned int fmt_xlong(char *dest,unsigned long src);
/* convert unsigned src integer 023 to ASCII '2','3', return length.
* If dest is not NULL, write result to dest */
unsigned int fmt_8long(char *dest,unsigned long src) __THROW;
unsigned int fmt_8long(char *dest,unsigned long src);
#define fmt_uint(dest,src) fmt_ulong(dest,src)
#define fmt_int(dest,src) fmt_long(dest,src)
@ -34,40 +34,40 @@ unsigned int fmt_8long(char *dest,unsigned long src) __THROW;
/* Like fmt_ulong, but prepend '0' while length is smaller than padto.
* Does not truncate! */
unsigned int fmt_ulong0(char *,unsigned long src,unsigned int padto) __THROW;
unsigned int fmt_ulong0(char *,unsigned long src,unsigned int padto);
#define fmt_uint0(buf,src,padto) fmt_ulong0(buf,src,padto)
/* convert src double 1.7 to ASCII '1','.','7', return length.
* If dest is not NULL, write result to dest */
unsigned int fmt_double(char *dest, double d,int max,int prec) __THROW;
unsigned int fmt_double(char *dest, double d,int max,int prec);
/* if src is negative, write '-' and return 1.
* if src is positive, write '+' and return 1.
* otherwise return 0 */
unsigned int fmt_plusminus(char *dest,int src) __THROW;
unsigned int fmt_plusminus(char *dest,int src);
/* if src is negative, write '-' and return 1.
* otherwise return 0. */
unsigned int fmt_minus(char *dest,int src) __THROW;
unsigned int fmt_minus(char *dest,int src);
/* copy str to dest until \0 byte, return number of copied bytes. */
unsigned int fmt_str(char *dest,const char *src) __THROW;
unsigned int fmt_str(char *dest,const char *src);
/* copy str to dest until \0 byte or limit bytes copied.
* return number of copied bytes. */
unsigned int fmt_strn(char *dest,const char *src,unsigned int limit) __THROW;
unsigned int fmt_strn(char *dest,const char *src,unsigned int limit);
/* "foo" -> " foo"
* write padlen-srclen spaces, if that is >= 0. Then copy srclen
* characters from src. Truncate only if total length is larger than
* maxlen. Return number of characters written. */
unsigned int fmt_pad(char* dest,const char* src,unsigned int srclen,unsigned int padlen,unsigned int maxlen) __THROW;
unsigned int fmt_pad(char* dest,const char* src,unsigned int srclen,unsigned int padlen,unsigned int maxlen);
/* "foo" -> "foo "
* append padlen-srclen spaces after dest, if that is >= 0. Truncate
* only if total length is larger than maxlen. Return number of
* characters written. */
unsigned int fmt_fill(char* dest,unsigned int srclen,unsigned int padlen,unsigned int maxlen) __THROW;
unsigned int fmt_fill(char* dest,unsigned int srclen,unsigned int padlen,unsigned int maxlen);
#endif

@ -1,19 +1,17 @@
#ifndef MMAP_H
#define MMAP_H
#include <sys/cdefs.h>
/* open file for reading, mmap whole file, close file, write length of
* map in filesize and return pointer to map. */
extern char* mmap_read(const char *filename,unsigned long* filesize) __THROW;
extern char* mmap_read(const char *filename,unsigned long* filesize);
/* open file for writing, mmap whole file privately (copy on write),
* close file, write length of map in filesize and return pointer to
* map. */
extern int mmap_write(const char *filename,unsigned long* filesize) __THROW;
extern int mmap_write(const char *filename,unsigned long* filesize);
/* open file for writing, mmap whole file shared, close file, write
* length of map in filesize and return pointer to map. */
extern int mmap_shared(const char *filename,unsigned long* filesize) __THROW;
extern int mmap_shared(const char *filename,unsigned long* filesize);
#endif

@ -1,29 +1,27 @@
#ifndef OPEN_H
#define OPEN_H
#include <sys/cdefs.h>
/* open filename for reading and return the file handle or -1 on error */
extern int open_read(const char *filename) __THROW;
extern int open_read(const char *filename);
/* create filename for exclusive write only use (mode 0600) and return
* the file handle or -1 on error */
extern int open_excl(const char *filename) __THROW;
extern int open_excl(const char *filename);
/* open filename for appending write only use (mode 0600)
* and return the file handle or -1 on error.
* All write operation will append after the last byte, regardless of
* seeking or other processes also appending to the file. The file will
* be created if it does not exist. */
extern int open_append(const char *filename) __THROW;
extern int open_append(const char *filename);
/* open filename for writing (mode 0644). Create the file if it does
* not exist, truncate it to zero length otherwise. Return the file
* handle or -1 on error. */
extern int open_trunc(const char *filename) __THROW;
extern int open_trunc(const char *filename);
/* open filename for writing. Create the file if it does not exist.
* Return the file handle or -1 on error. */
extern int open_write(const char *filename) __THROW;
extern int open_write(const char *filename);
#endif

@ -5,57 +5,54 @@
#ifndef __pure__
#define __pure__
#endif
#ifndef __THROW
#define __THROW
#endif
/* interpret src as ASCII decimal number, write number to dest and
* return the number of bytes that were parsed */
extern unsigned int scan_ulong(const char *src,unsigned long *dest) __THROW;
extern unsigned int scan_ulong(const char *src,unsigned long *dest);
/* interpret src as ASCII hexadecimal number, write number to dest and
* return the number of bytes that were parsed */
extern unsigned int scan_xlong(const char *src,unsigned long *dest) __THROW;
extern unsigned int scan_xlong(const char *src,unsigned long *dest);
/* interpret src as ASCII octal number, write number to dest and
* return the number of bytes that were parsed */
extern unsigned int scan_8long(const char *src,unsigned long *dest) __THROW;
extern unsigned int scan_8long(const char *src,unsigned long *dest);
/* interpret src as signed ASCII decimal number, write number to dest
* and return the number of bytes that were parsed */
extern unsigned int scan_long(const char *src,signed long *dest) __THROW;
extern unsigned int scan_long(const char *src,signed long *dest);
extern unsigned int scan_uint(const char *src,unsigned int *dest) __THROW;
extern unsigned int scan_xint(const char *src,unsigned int *dest) __THROW;
extern unsigned int scan_8int(const char *src,unsigned int *dest) __THROW;
extern unsigned int scan_int(const char *src,signed int *dest) __THROW;
extern unsigned int scan_uint(const char *src,unsigned int *dest);
extern unsigned int scan_xint(const char *src,unsigned int *dest);
extern unsigned int scan_8int(const char *src,unsigned int *dest);
extern unsigned int scan_int(const char *src,signed int *dest);
extern unsigned int scan_ushort(const char *src,unsigned short *dest) __THROW;
extern unsigned int scan_xshort(const char *src,unsigned short *dest) __THROW;
extern unsigned int scan_8short(const char *src,unsigned short *dest) __THROW;
extern unsigned int scan_short(const char *src,signed short *dest) __THROW;
extern unsigned int scan_ushort(const char *src,unsigned short *dest);
extern unsigned int scan_xshort(const char *src,unsigned short *dest);
extern unsigned int scan_8short(const char *src,unsigned short *dest);
extern unsigned int scan_short(const char *src,signed short *dest);
/* interpret src as double precision floating point number,
* write number to dest and return the number of bytes that were parsed */
extern unsigned int scan_double(const char *in, double *dest) __THROW;
extern unsigned int scan_double(const char *in, double *dest);
/* if *src=='-', set *dest to -1 and return 1.
* if *src=='+', set *dest to 1 and return 1.
* otherwise set *dest to 1 return 0. */
extern unsigned int scan_plusminus(const char *src,signed int *dest) __THROW;
extern unsigned int scan_plusminus(const char *src,signed int *dest);
/* return the highest integer n<=limit so that isspace(in[i]) for all 0<=i<=n */
extern unsigned int scan_whitenskip(const char *in,unsigned int limit) __THROW __pure__;
extern unsigned int scan_whitenskip(const char *in,unsigned int limit) __pure__;
/* return the highest integer n<=limit so that !isspace(in[i]) for all 0<=i<=n */
extern unsigned int scan_nonwhitenskip(const char *in,unsigned int limit) __THROW __pure__;
extern unsigned int scan_nonwhitenskip(const char *in,unsigned int limit) __pure__;
/* return the highest integer n<=limit so that in[i] is element of
* charset (ASCIIZ string) for all 0<=i<=n */
extern unsigned int scan_charsetnskip(const char *in,const char *charset,unsigned int limit) __THROW __pure__;
extern unsigned int scan_charsetnskip(const char *in,const char *charset,unsigned int limit) __pure__;
/* return the highest integer n<=limit so that in[i] is not element of
* charset (ASCIIZ string) for all 0<=i<=n */
extern unsigned int scan_noncharsetnskip(const char *in,const char *charset,unsigned int limit) __THROW __pure__;
extern unsigned int scan_noncharsetnskip(const char *in,const char *charset,unsigned int limit) __pure__;
#endif

17
str.h

@ -5,20 +5,17 @@
#ifndef __pure__
#define __pure__
#endif
#ifndef __THROW
#define __THROW
#endif
/* str_copy copies leading bytes from in to out until \0.
* return number of copied bytes. */
extern unsigned int str_copy(char *out,const char *in) __THROW;
extern unsigned int str_copy(char *out,const char *in);
/* str_diff returns negative, 0, or positive, depending on whether the
* string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than,
* equal to, or greater than the string b[0], b[1], ..., b[m-1]=='\0'.
* If the strings are different, str_diff does not read bytes past the
* first difference. */
extern int str_diff(const char *a,const char *b) __THROW __pure__;
extern int str_diff(const char *a,const char *b) __pure__;
/* str_diffn returns negative, 0, or positive, depending on whether the
* string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than,
@ -26,19 +23,19 @@ extern int str_diff(const char *a,const char *b) __THROW __pure__;
* If the strings are different, str_diffn does not read bytes past the
* first difference. The strings will be considered equal if the first
* limit characters match. */
extern int str_diffn(const char *a,const char *b,unsigned int limit) __THROW __pure__;
extern int str_diffn(const char *a,const char *b,unsigned int limit) __pure__;
/* str_len returns the index of \0 in s */
extern unsigned int str_len(const char *s) __THROW __pure__;
extern unsigned int str_len(const char *s) __pure__;
/* str_chr returns the index of the first occurance of needle or \0 in haystack */
extern unsigned int str_chr(const char *haystack,char needle) __THROW __pure__;
extern unsigned int str_chr(const char *haystack,char needle) __pure__;
/* str_rchr returns the index of the last occurance of needle or \0 in haystack */
extern unsigned int str_rchr(const char *haystack,char needle) __THROW __pure__;
extern unsigned int str_rchr(const char *haystack,char needle) __pure__;
/* str_start returns 1 if the b is a prefix of a, 0 otherwise */
extern int str_start(const char *a,const char *b) __THROW __pure__;
extern int str_start(const char *a,const char *b) __pure__;
/* convenience shortcut to test for string equality */
#define str_equal(s,t) (!str_diff((s),(t)))

@ -15,60 +15,60 @@ typedef struct stralloc {
* not enough to hold len bytes, stralloc_ready allocates at least len
* bytes of space, copies the old string into the new space, frees the
* old space, and returns 1. Note that this changes sa.s. */
extern int stralloc_ready(stralloc* sa,unsigned int len) __THROW;
extern int stralloc_ready(stralloc* sa,unsigned int len);
/* stralloc_readyplus is like stralloc_ready except that, if sa is
* already allocated, stralloc_readyplus adds the current length of sa
* to len. */
extern int stralloc_readyplus(stralloc* sa,unsigned int len) __THROW;
extern int stralloc_readyplus(stralloc* sa,unsigned int len);
/* stralloc_copyb copies the string buf[0], buf[1], ..., buf[len-1] into
* sa, allocating space if necessary, and returns 1. If it runs out of
* memory, stralloc_copyb leaves sa alone and returns 0. */
extern int stralloc_copyb(stralloc* sa,const char* buf,unsigned int len) __THROW;
extern int stralloc_copyb(stralloc* sa,const char* buf,unsigned int len);
/* stralloc_copys copies a \0-terminated string from buf into sa,
* without the \0. It is the same as
* stralloc_copyb(&sa,buf,str_len(buf)). */
extern int stralloc_copys(stralloc* sa,const char* buf) __THROW;
extern int stralloc_copys(stralloc* sa,const char* buf);
/* stralloc_copy copies the string stored in sa2 into sa. It is the same
* as stralloc_copyb(&sa,sa2.s,sa2.len). sa2 must already be allocated. */
extern int stralloc_copy(stralloc* sa,stralloc* sa2) __THROW;
extern int stralloc_copy(stralloc* sa,stralloc* sa2);
/* stralloc_catb adds the string buf[0], buf[1], ... buf[len-1] to the
* end of the string stored in sa, allocating space if necessary, and
* returns 1. If sa is unallocated, stralloc_catb is the same as
* stralloc_copyb. If it runs out of memory, stralloc_catb leaves sa
* alone and returns 0. */
extern int stralloc_catb(stralloc* sa,const char* in,unsigned int len) __THROW;
extern int stralloc_catb(stralloc* sa,const char* in,unsigned int len);
/* stralloc_cats is analogous to stralloc_copys */
extern int stralloc_cats(stralloc* sa,const char* in) __THROW;
extern int stralloc_cats(stralloc* sa,const char* in);
/* stralloc_cat is analogous to stralloc_copy */
extern int stralloc_cat(stralloc* sa,stralloc* in) __THROW;
extern int stralloc_cat(stralloc* sa,stralloc* in);
/* stralloc_append adds one byte buf[0] to the end of the string stored
* in sa. It is the same as stralloc_catb(&sa,buf,1). */
extern int stralloc_append(stralloc* sa,const char* in) __THROW; /* beware: this takes a pointer to 1 char */
extern int stralloc_append(stralloc* sa,const char* in); /* beware: this takes a pointer to 1 char */
/* stralloc_starts returns 1 if the \0-terminated string in buf, without
* the terminating \0, is a prefix of the string stored in sa. Otherwise
* it returns 0. sa must already be allocated. */
extern int stralloc_starts(stralloc* sa,const char* in) __THROW;
extern int stralloc_starts(stralloc* sa,const char* in);
/* stralloc_0 appends \0 */
#define stralloc_0(sa) stralloc_append(sa,"")
/* stralloc_catulong0 appends a '0' padded ASCII representation of in */
extern int stralloc_catulong0(stralloc* sa,unsigned long in,unsigned int n) __THROW;
extern int stralloc_catulong0(stralloc* sa,unsigned long in,unsigned int n);
/* stralloc_catlong0 appends a '0' padded ASCII representation of in */
extern int stralloc_catlong0(stralloc* sa,signed long in,unsigned int n) __THROW;
extern int stralloc_catlong0(stralloc* sa,signed long in,unsigned int n);
/* stralloc_free frees the storage associated with sa */
extern void stralloc_free(stralloc* sa) __THROW;
extern void stralloc_free(stralloc* sa);
#define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0))
#define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n)))

@ -6,10 +6,10 @@
typedef unsigned short uint16;
#ifdef NO_UINT16_MACROS
extern void uint16_pack(char *out,uint16 in) __THROW;
extern void uint16_pack_big(char *out,uint16 in) __THROW;
extern void uint16_unpack(const char *in,uint16* out) __THROW;
extern void uint16_unpack_big(const char *in,uint16* out) __THROW;
extern void uint16_pack(char *out,uint16 in);
extern void uint16_pack_big(char *out,uint16 in);
extern void uint16_unpack(const char *in,uint16* out);
extern void uint16_unpack_big(const char *in,uint16* out);
#else
#include <endian.h>
@ -18,19 +18,19 @@ extern void uint16_unpack_big(const char *in,uint16* out) __THROW;
#define uint16_pack(out,in) (*(short*)(out)=(in))
extern void uint16_pack_big(char *out,uint16 in) __THROW;
extern void uint16_pack_big(char *out,uint16 in);
#define uint16_unpack(in,out) (*(out)=*(short*)(in))
extern void uint16_unpack_big(const char *in,uint16* out) __THROW;
extern void uint16_unpack_big(const char *in,uint16* out);
#else
extern void uint16_pack(char *out,uint16 in) __THROW;
extern void uint16_pack(char *out,uint16 in);
#define uint16_pack_big(out,in) (*(short*)(out)=(in))
extern void uint16_unpack(const char *in,uint16* out) __THROW;
extern void uint16_unpack(const char *in,uint16* out);
#define uint16_unpack_big(in,out) (*(out)=*(short*)(in))

@ -1,15 +1,13 @@
#ifndef UINT32_H
#define UINT32_H
#include <sys/cdefs.h>
typedef unsigned int uint32;
#ifdef NO_UINT32_MACROS
extern void uint32_pack(char *out,uint32 in) __THROW;
extern void uint32_pack_big(char *out,uint32 in) __THROW;
extern void uint32_unpack(const char *in,uint32* out) __THROW;
extern void uint32_unpack_big(const char *in,uint32* out) __THROW;
extern void uint32_pack(char *out,uint32 in);
extern void uint32_pack_big(char *out,uint32 in);
extern void uint32_unpack(const char *in,uint32* out);
extern void uint32_unpack_big(const char *in,uint32* out);
#else
#include <endian.h>
@ -18,19 +16,19 @@ extern void uint32_unpack_big(const char *in,uint32* out) __THROW;
#define uint32_pack(out,in) (*(uint32*)(out)=(in))
extern void uint32_pack_big(char *out,uint32 in) __THROW;
extern void uint32_pack_big(char *out,uint32 in);
#define uint32_unpack(in,out) (*(out)=*(uint32*)(in))
extern void uint32_unpack_big(const char *in,uint32* out) __THROW;
extern void uint32_unpack_big(const char *in,uint32* out);
#else
extern void uint32_pack(char *out,uint32 in) __THROW;
extern void uint32_pack(char *out,uint32 in);
#define uint32_pack_big(out,in) (*(uint32*)(out)=(in))
extern void uint32_unpack(const char *in,uint32* out) __THROW;
extern void uint32_unpack(const char *in,uint32* out);
#define uint32_unpack_big(in,out) (*(out)=*(uint32*)(in))

@ -1,8 +1,7 @@
#ifndef UINT64_H
#define UINT64_H
#include <sys/cdefs.h>
#include <limits.h>
#include <endian.h>
#if __WORDSIZE == 64
typedef unsigned long uint64;

Loading…
Cancel
Save