ソースを参照

gcc 4 cleanups (mostly unsigned char* vs char*)

master
Felix von Leitner 15年前
コミット
8b636109ab
69個のファイルの変更119行の追加103行の削除
  1. +1
    -0
      CHANGES
  2. +3
    -1
      GNUmakefile
  3. +1
    -1
      Makefile
  4. +18
    -18
      buffer.h
  5. +3
    -0
      buffer/buffer_fromsa.c
  6. +1
    -1
      buffer/buffer_get.3
  7. +1
    -1
      buffer/buffer_get.c
  8. +1
    -1
      buffer/buffer_get_new_token_sa.c
  9. +2
    -2
      buffer/buffer_get_token.3
  10. +1
    -1
      buffer/buffer_get_token.c
  11. +2
    -2
      buffer/buffer_get_token_pred.3
  12. +1
    -1
      buffer/buffer_get_token_pred.c
  13. +1
    -1
      buffer/buffer_get_token_sa.3
  14. +1
    -1
      buffer/buffer_get_token_sa.c
  15. +1
    -1
      buffer/buffer_getc.3
  16. +1
    -1
      buffer/buffer_getc.c
  17. +1
    -1
      buffer/buffer_getline.3
  18. +1
    -1
      buffer/buffer_getline.c
  19. +1
    -1
      buffer/buffer_getn.3
  20. +1
    -1
      buffer/buffer_getn.c
  21. +1
    -1
      buffer/buffer_init.3
  22. +1
    -1
      buffer/buffer_init.c
  23. +1
    -1
      buffer/buffer_init_free.3
  24. +1
    -1
      buffer/buffer_init_free.c
  25. +1
    -1
      buffer/buffer_put.3
  26. +2
    -2
      buffer/buffer_put.c
  27. +1
    -1
      buffer/buffer_put8long.c
  28. +1
    -1
      buffer/buffer_putalign.3
  29. +1
    -1
      buffer/buffer_putalign.c
  30. +1
    -1
      buffer/buffer_putflush.3
  31. +1
    -1
      buffer/buffer_putflush.c
  32. +1
    -1
      buffer/buffer_putlong.c
  33. +1
    -1
      buffer/buffer_putlonglong.c
  34. +1
    -1
      buffer/buffer_putm_internal.c
  35. +1
    -1
      buffer/buffer_putm_internal_flush.c
  36. +1
    -1
      buffer/buffer_puts.3
  37. +1
    -1
      buffer/buffer_puts.c
  38. +1
    -1
      buffer/buffer_putsalign.3
  39. +1
    -1
      buffer/buffer_putsalign.c
  40. +1
    -1
      buffer/buffer_putsflush.3
  41. +1
    -1
      buffer/buffer_putsflush.c
  42. +1
    -1
      buffer/buffer_putxlong.c
  43. +1
    -1
      buffer/buffer_stubborn.c
  44. +1
    -1
      buffer/buffer_stubborn2.c
  45. +1
    -1
      io/io_passfd.c
  46. +5
    -4
      io/iob_send.c
  47. +5
    -4
      io/iob_write.c
  48. +3
    -3
      ip6.h
  49. +2
    -2
      str/str_diff.c
  50. +2
    -2
      str/str_diffn.c
  51. +1
    -0
      str/str_len.c
  52. +7
    -7
      stralloc.h
  53. +1
    -1
      stralloc/stralloc_append.3
  54. +1
    -1
      stralloc/stralloc_append.c
  55. +1
    -1
      stralloc/stralloc_catb.3
  56. +1
    -1
      stralloc/stralloc_catb.c
  57. +1
    -1
      stralloc/stralloc_catm.3
  58. +1
    -1
      stralloc/stralloc_cats.3
  59. +1
    -1
      stralloc/stralloc_cats.c
  60. +1
    -1
      stralloc/stralloc_copyb.3
  61. +1
    -1
      stralloc/stralloc_copyb.c
  62. +1
    -1
      stralloc/stralloc_copys.3
  63. +1
    -1
      stralloc/stralloc_copys.c
  64. +1
    -1
      stralloc/stralloc_diff.c
  65. +1
    -1
      stralloc/stralloc_diffs.3
  66. +2
    -2
      stralloc/stralloc_diffs.c
  67. +1
    -1
      stralloc/stralloc_starts.3
  68. +1
    -1
      stralloc/stralloc_starts.c
  69. +8
    -1
      t.c

+ 1
- 0
CHANGES ファイルの表示

@@ -2,6 +2,7 @@
also recognize EPFNOSUPPORT as EAFNOSUPPORT (groan)
fix a few man pages
optimize fmt_base64 (Dan Gundlach)
gcc 4 cleanups (mostly unsigned char* vs char*)

0.22:
uh, the scope_id detection #defined the wrong constant. libowfat


+ 3
- 1
GNUmakefile ファイルの表示

@@ -15,9 +15,11 @@ buffer.a mmap.a taia.a tai.a dns.a case.a mult.a array.a io.a textcode.a
all: t $(LIBS) libowfat.a libsocket

CC=gcc
CFLAGS=-pipe -Wall -O2 -fomit-frame-pointer
CFLAGS=-pipe -W -Wall -O2 -fomit-frame-pointer
#CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall

CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2

# startrip
ifneq ($(DEBUG),)
CFLAGS=-pipe -Wall -g


+ 1
- 1
Makefile ファイルの表示

@@ -16,7 +16,7 @@ buffer.a mmap.a taia.a tai.a dns.a case.a mult.a array.a io.a textcode.a
all: t $(LIBS) libowfat.a libsocket

CC=gcc
CFLAGS=-pipe -Wall -O2 -fomit-frame-pointer
CFLAGS=-pipe -W -Wall -O2 -fomit-frame-pointer
#CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall

array_allocate.o: array/array_allocate.c safemult.h uint16.h \


+ 18
- 18
buffer.h ファイルの表示

@@ -2,7 +2,7 @@
#define BUFFER_H

typedef struct buffer {
unsigned char *x; /* actual buffer space */
char *x; /* actual buffer space */
unsigned long int p; /* current position */
unsigned long int n; /* current size of string in buffer */
unsigned long int a; /* allocated buffer size */
@@ -17,18 +17,18 @@ typedef struct buffer {
#define BUFFER_INSIZE 8192
#define BUFFER_OUTSIZE 8192

void buffer_init(buffer* b,int (*op)(),int fd,unsigned char* y,unsigned long int ylen);
void buffer_init_free(buffer* b,int (*op)(),int fd,unsigned char* y,unsigned long int ylen);
void buffer_init(buffer* b,int (*op)(),int fd,char* y,unsigned long int ylen);
void buffer_init_free(buffer* b,int (*op)(),int fd,char* y,unsigned long int ylen);
int buffer_mmapread(buffer* b,const char* filename);
void buffer_close(buffer* b);

int buffer_flush(buffer* b);
int buffer_put(buffer* b,const unsigned char* x,unsigned long int len);
int buffer_putalign(buffer* b,const unsigned char* x,unsigned long int len);
int buffer_putflush(buffer* b,const unsigned char* x,unsigned long int len);
int buffer_puts(buffer* b,const unsigned char* x);
int buffer_putsalign(buffer* b,const unsigned char* x);
int buffer_putsflush(buffer* b,const unsigned char* x);
int buffer_put(buffer* b,const char* x,unsigned long int len);
int buffer_putalign(buffer* b,const char* x,unsigned long int len);
int buffer_putflush(buffer* b,const char* x,unsigned long int len);
int buffer_puts(buffer* b,const char* x);
int buffer_putsalign(buffer* b,const char* x);
int buffer_putsflush(buffer* b,const char* x);

int buffer_putm_internal(buffer*b,...);
int buffer_putm_internal_flush(buffer*b,...);
@@ -44,24 +44,24 @@ int buffer_putnlflush(buffer* b); /* put \n and flush */
: buffer_put((s),&(c),1) \
)

int buffer_get(buffer* b,unsigned char* x,unsigned long int len);
int buffer_get(buffer* b,char* x,unsigned long int len);
int buffer_feed(buffer* b);
int buffer_getc(buffer* b,unsigned char* x);
int buffer_getn(buffer* b,unsigned char* x,unsigned long int len);
int buffer_getc(buffer* b,char* x);
int buffer_getn(buffer* b,char* x,unsigned long int len);

/* read bytes until the destination buffer is full (len bytes), end of
* file is reached or the read char is in charset (setlen bytes). An
* empty line when looking for \n will write '\n' to x and return 0. If
* EOF is reached, \0 is written to the buffer */
int buffer_get_token(buffer* b,unsigned char* x,unsigned long int len,const unsigned char* charset,unsigned long int setlen);
int buffer_getline(buffer* b,unsigned char* x,unsigned long int len);
int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen);
int buffer_getline(buffer* b,char* x,unsigned long int len);

/* this predicate is given the string as currently read from the buffer
* and is supposed to return 1 if the token is complete, 0 if not. */
typedef int (*string_predicate)(const unsigned char* x,unsigned long int len);
typedef int (*string_predicate)(const char* x,unsigned long int len);

/* like buffer_get_token but the token ends when your predicate says so */
int buffer_get_token_pred(buffer* b,unsigned char* x,unsigned long int len,string_predicate p);
int buffer_get_token_pred(buffer* b,char* x,unsigned long int len,string_predicate p);

char *buffer_peek(buffer* b);
void buffer_seek(buffer* b,unsigned long int len);
@@ -112,12 +112,12 @@ int buffer_putsaflush(buffer* b,stralloc* sa);
* data is available. */

/* read token from buffer to stralloc */
int buffer_get_token_sa(buffer* b,stralloc* sa,const unsigned char* charset,unsigned long int setlen);
int buffer_get_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen);
/* read line from buffer to stralloc */
int buffer_getline_sa(buffer* b,stralloc* sa);

/* same as buffer_get_token_sa but empty sa first */
int buffer_get_new_token_sa(buffer* b,stralloc* sa,const unsigned char* charset,unsigned long int setlen);
int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen);
/* same as buffer_getline_sa but empty sa first */
int buffer_getnewline_sa(buffer* b,stralloc* sa);



+ 3
- 0
buffer/buffer_fromsa.c ファイルの表示

@@ -2,6 +2,9 @@
#include "buffer.h"

static int dummyreadwrite(int fd,char* buf,unsigned long int len) {
(void)fd;
(void)buf;
(void)len;
return 0;
}



+ 1
- 1
buffer/buffer_get.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_get \- read binary data from buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_get\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR);
int \fBbuffer_get\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
Normally buffer_get copies data to \fIx\fR[0], \fIx\fR[1], ...,
\fIx\fR[\fIlen\fR-1] from the beginning of a string stored in


+ 1
- 1
buffer/buffer_get.c ファイルの表示

@@ -1,7 +1,7 @@
#include "byte.h"
#include "buffer.h"

int buffer_get(buffer* b,unsigned char* x,unsigned long int len) {
int buffer_get(buffer* b,char* x,unsigned long int len) {
int blen;
if ((blen=buffer_feed(b))>=len)
blen=len;


+ 1
- 1
buffer/buffer_get_new_token_sa.c ファイルの表示

@@ -1,7 +1,7 @@
#include "stralloc.h"
#include "buffer.h"

int buffer_get_new_token_sa(buffer* b,stralloc* sa,const unsigned char* charset,unsigned long int setlen) {
int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen) {
stralloc_zero(sa);
return buffer_get_token_sa(b,sa,charset,setlen);
}

+ 2
- 2
buffer/buffer_get_token.3 ファイルの表示

@@ -4,8 +4,8 @@ buffer_get_token \- read token from buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_get_token\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR,
const unsigned char* \fIcharset\fR,unsigned long int \fIsetlen\fR);
int \fBbuffer_get_token\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR,
const char* \fIcharset\fR,unsigned long int \fIsetlen\fR);
.SH DESCRIPTION
buffer_get_token copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ...,
\fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been copied or one of


+ 1
- 1
buffer/buffer_get_token.c ファイルの表示

@@ -2,7 +2,7 @@
#include "buffer.h"
#include "scan.h"

int buffer_get_token(buffer* b,unsigned char* x,unsigned long int len,const unsigned char* charset,unsigned long int setlen) {
int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen) {
int blen;

for (blen=0;blen<len;++blen) {


+ 2
- 2
buffer/buffer_get_token_pred.3 ファイルの表示

@@ -4,8 +4,8 @@ buffer_get_token_pred \- read token from buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_get_token_pred\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR,
int (*\fIpredicate\fR)(const unsigned char* \fIs\fR,unsigned long int \fIlen\fR));
int \fBbuffer_get_token_pred\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR,
int (*\fIpredicate\fR)(const char* \fIs\fR,unsigned long int \fIlen\fR));
.SH DESCRIPTION
buffer_get_token_pred copies data from \fIb\fR to \fIx\fR[0],
\fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been


+ 1
- 1
buffer/buffer_get_token_pred.c ファイルの表示

@@ -2,7 +2,7 @@
#include "buffer.h"
#include "scan.h"

int buffer_get_token_pred(buffer* b,unsigned char* x,unsigned long int len,
int buffer_get_token_pred(buffer* b,char* x,unsigned long int len,
string_predicate p) {
int blen;



+ 1
- 1
buffer/buffer_get_token_sa.3 ファイルの表示

@@ -7,7 +7,7 @@ buffer_get_token_sa \- read token from buffer
.B #include <buffer.h>

int \fBbuffer_get_token_sa\fP(buffer* \fIb\fR,stralloc* \fIsa\fR,
const unsigned char* \fIcharset\fR,unsigned long int \fIsetlen\fR);
const char* \fIcharset\fR,unsigned long int \fIsetlen\fR);
.SH DESCRIPTION
buffer_get_token_sa appends data from the \fIb\fR to \fIsa\fR until one
of the delimiters in \fIcharset\fR is found, NOT overwriting the


+ 1
- 1
buffer/buffer_get_token_sa.c ファイルの表示

@@ -4,7 +4,7 @@
#include <errno.h>

int buffer_get_token_sa(buffer* b,stralloc* sa,
const unsigned char* charset,
const char* charset,
unsigned long int setlen) {
for (;;) {
char x;


+ 1
- 1
buffer/buffer_getc.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_getc \- read one char from buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_getc\fP(buffer* \fIb\fR,unsigned char* \fIx\fR);
int \fBbuffer_getc\fP(buffer* \fIb\fR,char* \fIx\fR);
.SH DESCRIPTION
buffer_getc(b,x) is similar to buffer_get(b,x,1).
.SH "SEE ALSO"


+ 1
- 1
buffer/buffer_getc.c ファイルの表示

@@ -1,7 +1,7 @@
#include "byte.h"
#include "buffer.h"

int buffer_getc(buffer* b,unsigned char* x) {
int buffer_getc(buffer* b,char* x) {
if (b->p==b->n) {
register int blen;
if ((blen=buffer_feed(b))<=0) return blen;


+ 1
- 1
buffer/buffer_getline.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_getline \- read line from buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_getline\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR);
int \fBbuffer_getline\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
buffer_getline copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ...,
\fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been copied or a


+ 1
- 1
buffer/buffer_getline.c ファイルの表示

@@ -1,5 +1,5 @@
#include <buffer.h>

int buffer_getline(buffer* b,unsigned char* x,unsigned long int len) {
int buffer_getline(buffer* b,char* x,unsigned long int len) {
return buffer_get_token(b,x,len,"\n",1);
}

+ 1
- 1
buffer/buffer_getn.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_getn \- read binary data from buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_getn\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR);
int \fBbuffer_getn\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
buffer_getn copies data to \fIx\fR[0], \fIx\fR[1], ...,
\fIx\fR[\fIlen\fR-1] from the buffer, calling buffer_feed as needed, and


+ 1
- 1
buffer/buffer_getn.c ファイルの表示

@@ -1,7 +1,7 @@
#include "byte.h"
#include "buffer.h"

int buffer_getn(buffer* b,unsigned char* x,unsigned long int len) {
int buffer_getn(buffer* b,char* x,unsigned long int len) {
int blen;

for(blen=0;blen<len;++blen) {


+ 1
- 1
buffer/buffer_init.3 ファイルの表示

@@ -6,7 +6,7 @@ buffer_init \- initialize buffer structure

void \fBbuffer_init\fR(buffer &\fIb\fR,
int (*\fIop\fR)(int,char*,unsigned int),
int \fIfd\fR, unsigned char* \fIy\fR, unsigned long int \fIylen\fR);
int \fIfd\fR, char* \fIy\fR, unsigned long int \fIylen\fR);
.SH DESCRIPTION
buffer_init prepares \fIb\fR to store a string in \fIy\fR[0], \fIy\fR[1], ...,
\fIy\fR[\fIylen\fR-1]. Initially the string is empty.


+ 1
- 1
buffer/buffer_init.c ファイルの表示

@@ -1,7 +1,7 @@
#include "buffer.h"

void buffer_init(buffer* b,int (*op)(),int fd,
unsigned char* y,unsigned long int ylen) {
char* y,unsigned long int ylen) {
b->op=op;
b->fd=fd;
b->x=y;


+ 1
- 1
buffer/buffer_init_free.3 ファイルの表示

@@ -6,7 +6,7 @@ buffer_init_free \- initialize buffer structure

void \fBbuffer_init_free\fR(buffer &\fIb\fR,
int (*\fIop\fR)(int,char*,unsigned int),
int \fIfd\fR, unsigned char* \fIy\fR, unsigned long int \fIylen\fR);
int \fIfd\fR, char* \fIy\fR, unsigned long int \fIylen\fR);
.SH DESCRIPTION
buffer_init_free is like buffer_init except that the memory (\fIy\fR is
marked to be freed by buffer_close().


+ 1
- 1
buffer/buffer_init_free.c ファイルの表示

@@ -1,7 +1,7 @@
#include "buffer.h"

void buffer_init_free(buffer* b,int (*op)(),int fd,
unsigned char* y,unsigned long int ylen) {
char* y,unsigned long int ylen) {
buffer_init(b,op,fd,y,ylen);
b->todo=FREE;
}

+ 1
- 1
buffer/buffer_put.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_put \- write binary data to buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_put\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR,unsigned long int \fIlen\fR);
int \fBbuffer_put\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
buffer_put writes \fIlen\fR bytes from \fIx\fR to \fIb\fR.



+ 2
- 2
buffer/buffer_put.c ファイルの表示

@@ -1,9 +1,9 @@
#include "byte.h"
#include "buffer.h"

extern int buffer_stubborn(int (*op)(),int fd,const unsigned char* buf, unsigned long int len);
extern int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned long int len);

int buffer_put(buffer* b,const unsigned char* buf,unsigned long int len) {
int buffer_put(buffer* b,const char* buf,unsigned long int len) {
if (len>b->a-b->p) { /* doesn't fit */
if (buffer_flush(b)==-1) return -1;
if (len>b->a) {


+ 1
- 1
buffer/buffer_put8long.c ファイルの表示

@@ -2,7 +2,7 @@
#include "fmt.h"

int buffer_put8long(buffer *b,unsigned long l) {
unsigned char buf[FMT_8LONG];
char buf[FMT_8LONG];
return buffer_put(b,buf,fmt_8long(buf,l));
}


+ 1
- 1
buffer/buffer_putalign.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_putalign \- write binary data to buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_putalign\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR,unsigned long int \fIlen\fR);
int \fBbuffer_putalign\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
buffer_putalign is similar to buffer_put.



+ 1
- 1
buffer/buffer_putalign.c ファイルの表示

@@ -1,7 +1,7 @@
#include "byte.h"
#include "buffer.h"

int buffer_putalign(buffer* b,const unsigned char* buf,unsigned long int len) {
int buffer_putalign(buffer* b,const char* buf,unsigned long int len) {
int tmp;
while (len>(tmp=b->a-b->p)) {
byte_copy(b->x+b->p, tmp, buf);


+ 1
- 1
buffer/buffer_putflush.3 ファイルの表示

@@ -5,7 +5,7 @@ buffer_putflush \- write binary data to buffer and flush
.B #include <buffer.h>

int \fBbuffer_putflush\fP(buffer* \fIb\fR,
const unsigned char* \fIx\fR,unsigned long int \fIlen\fR);
const char* \fIx\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
buffer_putflush is similar to calling
buffer_put(\fIb\fR,\fIx\fR,\fIlen\fR) and then buffer_flush(\fIb\fR).


+ 1
- 1
buffer/buffer_putflush.c ファイルの表示

@@ -1,6 +1,6 @@
#include "buffer.h"

int buffer_putflush(buffer* b,const unsigned char* x,unsigned long int len) {
int buffer_putflush(buffer* b,const char* x,unsigned long int len) {
if (buffer_put(b,x,len)<0) return -1;
if (buffer_flush(b)<0) return -1;
return 0;


+ 1
- 1
buffer/buffer_putlong.c ファイルの表示

@@ -2,7 +2,7 @@
#include "fmt.h"

int buffer_putlong(buffer *b,signed long l) {
unsigned char buf[FMT_LONG];
char buf[FMT_LONG];
return buffer_put(b,buf,fmt_long(buf,l));
}


+ 1
- 1
buffer/buffer_putlonglong.c ファイルの表示

@@ -2,7 +2,7 @@
#include "fmt.h"

int buffer_putlonglong(buffer *b,signed long long l) {
unsigned char buf[FMT_LONG];
char buf[FMT_LONG];
return buffer_put(b,buf,fmt_longlong(buf,l));
}


+ 1
- 1
buffer/buffer_putm_internal.c ファイルの表示

@@ -6,7 +6,7 @@ int buffer_putm_internal(buffer* b, ...) {
va_list a;
const char* s;
va_start(a,b);
while ((s=va_arg(a,const unsigned char*)))
while ((s=va_arg(a,const char*)))
if (buffer_puts(b,s)==-1) {
r=-1;
break;


+ 1
- 1
buffer/buffer_putm_internal_flush.c ファイルの表示

@@ -6,7 +6,7 @@ int buffer_putm_internal_flush(buffer* b, ...) {
va_list a;
const char* s;
va_start(a,b);
while ((s=va_arg(a,const unsigned char*)))
while ((s=va_arg(a,const char*)))
if (buffer_puts(b,s)==-1) {
r=-1;
break;


+ 1
- 1
buffer/buffer_puts.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_puts \- write ASCIIZ string to buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_puts\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR);
int \fBbuffer_puts\fP(buffer* \fIb\fR,const char* \fIx\fR);
.SH DESCRIPTION
buffer_puts is like buffer_put with \fIlen\fR determined as the number
of bytes before the first \\0 in \fIx\fR.


+ 1
- 1
buffer/buffer_puts.c ファイルの表示

@@ -1,6 +1,6 @@
#include "str.h"
#include "buffer.h"

int buffer_puts(buffer* b,const unsigned char* x) {
int buffer_puts(buffer* b,const char* x) {
return buffer_put(b,x,str_len(x));
}

+ 1
- 1
buffer/buffer_putsalign.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_putsalign \- write ASCIIZ string to buffer
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_putsalign\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR);
int \fBbuffer_putsalign\fP(buffer* \fIb\fR,const char* \fIx\fR);
.SH DESCRIPTION
buffer_putsalign is like buffer_putalign with \fIlen\fR determined as
the number of bytes before the first \\0 in \fIx\fR.


+ 1
- 1
buffer/buffer_putsalign.c ファイルの表示

@@ -1,6 +1,6 @@
#include "str.h"
#include "buffer.h"

int buffer_putsalign(buffer* b,const unsigned char* x) {
int buffer_putsalign(buffer* b,const char* x) {
return buffer_putalign(b,x,str_len(x));
}

+ 1
- 1
buffer/buffer_putsflush.3 ファイルの表示

@@ -4,7 +4,7 @@ buffer_putsflush \- write ASCIIZ string to buffer and flush
.SH SYNTAX
.B #include <buffer.h>

int \fBbuffer_putsflush\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR);
int \fBbuffer_putsflush\fP(buffer* \fIb\fR,const char* \fIx\fR);
.SH DESCRIPTION
buffer_putsflush is like buffer_putflush with \fIlen\fR determined as
the number of bytes before the first \\0 in \fIx\fR.


+ 1
- 1
buffer/buffer_putsflush.c ファイルの表示

@@ -1,6 +1,6 @@
#include "str.h"
#include "buffer.h"

int buffer_putsflush(buffer* b,const unsigned char* x) {
int buffer_putsflush(buffer* b,const char* x) {
return buffer_putflush(b,x,str_len(x));
}

+ 1
- 1
buffer/buffer_putxlong.c ファイルの表示

@@ -2,7 +2,7 @@
#include "fmt.h"

int buffer_putxlong(buffer *b,unsigned long l) {
unsigned char buf[FMT_XLONG];
char buf[FMT_XLONG];
return buffer_put(b,buf,fmt_xlong(buf,l));
}


+ 1
- 1
buffer/buffer_stubborn.c ファイルの表示

@@ -1,7 +1,7 @@
#include <errno.h>
#include "buffer.h"

int buffer_stubborn(int (*op)(),int fd,const unsigned char* buf, unsigned long int len) {
int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned long int len) {
int w;
while (len) {
if ((w=op(fd,buf,len))<0) {


+ 1
- 1
buffer/buffer_stubborn2.c ファイルの表示

@@ -1,7 +1,7 @@
#include <errno.h>
#include "buffer.h"

int buffer_stubborn_read(int (*op)(),int fd,const unsigned char* buf, unsigned long int len) {
int buffer_stubborn_read(int (*op)(),int fd,const char* buf, unsigned long int len) {
int w;
for (;;) {
if ((w=op(fd,buf,len))<0)


+ 1
- 1
io/io_passfd.c ファイルの表示

@@ -22,7 +22,7 @@ union fdmsg {
};

int io_passfd(int64 sock,int64 fd) {
struct msghdr msg = {0};
struct msghdr msg;
struct iovec iov;
#ifdef CMSG_LEN
struct cmsghdr *cmsg;


+ 5
- 4
io/iob_send.c ファイルの表示

@@ -13,7 +13,8 @@
int64 iob_send(int64 s,io_batch* b) {
iob_entry* e,* last;
struct iovec* v;
int64 total,sent;
uint64 total;
int64 sent;
long i;
long headers;
#ifdef HAVE_BSDSENDFILE
@@ -101,8 +102,8 @@ eagain:
if (sent>0)
total+=sent;
else
return total?total:sent;
if (sent==b->bytesleft) {
return total?total:(uint64)sent;
if ((uint64)sent==b->bytesleft) {
#ifdef TCP_CORK
if (b->bufs && b->files) {
static int zero=0;
@@ -112,7 +113,7 @@ eagain:
iob_reset(b);
break;
} else if (sent>0) {
int64 rest=sent;
uint64 rest=sent;

b->bytesleft-=rest;
for (i=0; e+i<last; ++i) {


+ 5
- 4
io/iob_write.c ファイルの表示

@@ -2,7 +2,8 @@

int64 iob_write(int64 s,io_batch* b,io_write_callback cb) {
iob_entry* e,* last;
int64 total,sent;
uint64 total;
int64 sent;
long i;
int thatsit;

@@ -18,10 +19,10 @@ int64 iob_write(int64 s,io_batch* b,io_write_callback cb) {
sent=io_mmapwritefile(s,e[i].fd,e[i].offset,e[i].n,cb);
else
sent=cb(s,e[i].buf+e[i].offset,e[i].n);
if (sent>0 && sent>e[i].n) sent=e[i].n; /* can't happen */
thatsit=(sent != e[i].n);
if (sent>0 && (uint64)sent>e[i].n) sent=e[i].n; /* can't happen */
thatsit=((uint64)sent != e[i].n);
if (sent<=0)
return total?total:sent;
return total?total:(uint64)sent;
e[i].offset+=sent;
e[i].n-=sent;
total+=sent;


+ 3
- 3
ip6.h ファイルの表示

@@ -25,9 +25,9 @@ unsigned int fmt_ip6_flat(char *dest,const char *);

#define IP6_FMT 40

extern const unsigned char V4mappedprefix[12]; /*={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; */
extern const unsigned char V6loopback[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; */
extern const unsigned char V6any[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */
extern const char V4mappedprefix[12]; /*={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; */
extern const char V6loopback[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; */
extern const char V6any[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */

#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix))



+ 2
- 2
str/str_diff.c ファイルの表示

@@ -6,8 +6,8 @@
* When the strings are different, str_diff does not read bytes past the
* first difference. */
int str_diff(const char* a, const char* b) {
register const char* s=a;
register const char* t=b;
register const unsigned char* s=(const unsigned char*)a;
register const unsigned char* t=(const unsigned char*)b;
register int j;
j=0;
for (;;) {


+ 2
- 2
str/str_diffn.c ファイルの表示

@@ -6,8 +6,8 @@
* When the strings are different, str_diff does not read bytes past the
* first difference. */
int str_diffn(const char* a, const char* b, unsigned long limit) {
register const char* s=a;
register const char* t=b;
register const unsigned char* s=(const unsigned char*)a;
register const unsigned char* t=(const unsigned char*)b;
register const char* u=t+limit;
register int j;
j=0;


+ 1
- 0
str/str_len.c ファイルの表示

@@ -1,3 +1,4 @@
#undef __dietlibc__
#include "str.h"

unsigned long str_len(const char* in) {


+ 7
- 7
stralloc.h ファイルの表示

@@ -42,12 +42,12 @@ int stralloc_readyplus(stralloc* sa,unsigned long 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. */
int stralloc_copyb(stralloc* sa,const unsigned char* buf,unsigned long int len);
int stralloc_copyb(stralloc* sa,const char* buf,unsigned long 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)). */
int stralloc_copys(stralloc* sa,const unsigned char* buf);
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. */
@@ -58,10 +58,10 @@ int stralloc_copy(stralloc* sa,const stralloc* sa2);
* 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. */
int stralloc_catb(stralloc* sa,const unsigned char* in,unsigned long int len);
int stralloc_catb(stralloc* sa,const char* in,unsigned long int len);

/* stralloc_cats is analogous to stralloc_copys */
int stralloc_cats(stralloc* sa,const unsigned char* in);
int stralloc_cats(stralloc* sa,const char* in);

void stralloc_zero(stralloc* sa);

@@ -76,12 +76,12 @@ int stralloc_cat(stralloc* sa,stralloc* in);

/* stralloc_append adds one byte in[0] to the end of the string stored
* in sa. It is the same as stralloc_catb(&sa,in,1). */
int stralloc_append(stralloc* sa,const unsigned char* in); /* beware: this takes a pointer to 1 char */
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 "in", without
* the terminating \0, is a prefix of the string stored in sa. Otherwise
* it returns 0. sa must already be allocated. */
int stralloc_starts(stralloc* sa,const unsigned char* in) __pure__;
int stralloc_starts(stralloc* sa,const char* in) __pure__;

/* stralloc_diff returns negative, 0, or positive, depending on whether
* a is lexicographically smaller than, equal to, or greater than the
@@ -91,7 +91,7 @@ int stralloc_diff(const stralloc* a,const stralloc* b) __pure__;
/* stralloc_diffs returns negative, 0, or positive, depending on whether
* a is lexicographically smaller than, equal to, or greater than the
* string b[0], b[1], ..., b[n]=='\0'. */
int stralloc_diffs(const stralloc* a,const unsigned char* b) __pure__;
int stralloc_diffs(const stralloc* a,const char* b) __pure__;

#define stralloc_equal(a,b) (!stralloc_diff((a),(b)))
#define stralloc_equals(a,b) (!stralloc_diffs((a),(b)))


+ 1
- 1
stralloc/stralloc_append.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_append \- append a character to a stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_append\fP(stralloc* \fIsa\fR,const unsigned char* \fIin\fR);
int \fBstralloc_append\fP(stralloc* \fIsa\fR,const char* \fIin\fR);
.SH DESCRIPTION
stralloc_append appends the byte from *\fIbuf\fR to the
string stored in \fIsa\fR, allocating space if necessary, and


+ 1
- 1
stralloc/stralloc_append.c ファイルの表示

@@ -2,7 +2,7 @@

/* stralloc_append adds one byte in[0] to the end of the string stored
* in sa. It is the same as stralloc_catb(&sa,in,1). */
int stralloc_append(stralloc *sa,const unsigned char *in) {
int stralloc_append(stralloc *sa,const char *in) {
if (stralloc_readyplus(sa,1)) {
sa->s[sa->len]=*in;
++sa->len;


+ 1
- 1
stralloc/stralloc_catb.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_catb \- append data to a stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR,unsigned long int \fIlen\fR);
int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
stralloc_catb adds the string \fIbuf\fR[0], \fIbuf\fR[1], ... \fIbuf\fR[\fIlen\fR-1] to the
end of the string stored in \fIsa\fR, allocating space if necessary, and


+ 1
- 1
stralloc/stralloc_catb.c ファイルの表示

@@ -6,7 +6,7 @@
* 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. */
int stralloc_catb(stralloc *sa,const unsigned char *buf,unsigned long int len) {
int stralloc_catb(stralloc *sa,const char *buf,unsigned long int len) {
if (stralloc_readyplus(sa,len)) {
byte_copy(sa->s+sa->len,len,buf);
sa->len+=len;


+ 1
- 1
stralloc/stralloc_catm.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_catm \- append string(s) to a stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_catm\fP(stralloc* \fIsa\fR,const unsigned char* \fIs\fR, ...);
int \fBstralloc_catm\fP(stralloc* \fIsa\fR,const char* \fIs\fR, ...);
.SH DESCRIPTION
stralloc_catm appends \\0-terminated strings from \fIs\fR... to the
end of the string stored in \fIsa\fR, allocating space if necessary, and


+ 1
- 1
stralloc/stralloc_cats.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_cats \- append data to a stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR);
int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR);
.SH DESCRIPTION
stralloc_cats appends a \\0-terminated string from \fIbuf\fR to the
end of the string stored in \fIsa\fR, allocating space if necessary, and


+ 1
- 1
stralloc/stralloc_cats.c ファイルの表示

@@ -1,7 +1,7 @@
#include "stralloc.h"
#include "str.h"

extern int stralloc_cats(stralloc *sa,const unsigned char *buf) {
extern int stralloc_cats(stralloc *sa,const char *buf) {
return stralloc_catb(sa,buf,str_len(buf));
}


+ 1
- 1
stralloc/stralloc_copyb.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_copyb \- copy data into a stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR,unsigned long int \fIlen\fR);
int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned long int \fIlen\fR);
.SH DESCRIPTION
stralloc_copyb makes sure that \fIsa\fR has enough space allocated to hold
\fIlen\fR bytes. Then it copies the first \fIlen\fR bytes from


+ 1
- 1
stralloc/stralloc_copyb.c ファイルの表示

@@ -4,7 +4,7 @@
/* 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. */
int stralloc_copyb(stralloc *sa,const unsigned char *buf,unsigned long int len) {
int stralloc_copyb(stralloc *sa,const char *buf,unsigned long int len) {
if (stralloc_ready(sa,len)) {
sa->len=len;
byte_copy(sa->s,len,buf);


+ 1
- 1
stralloc/stralloc_copys.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_copys \- copy data into a stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR);
int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR);
.SH DESCRIPTION
stralloc_copys copies a \\0-terminated string from \fIbuf\fR into
\fIsa\fR, without the \\0. It is the same as


+ 1
- 1
stralloc/stralloc_copys.c ファイルの表示

@@ -1,7 +1,7 @@
#include "stralloc.h"
#include "str.h"

extern int stralloc_copys(stralloc *sa,const unsigned char *buf) {
extern int stralloc_copys(stralloc *sa,const char *buf) {
return stralloc_copyb(sa,buf,str_len(buf));
}


+ 1
- 1
stralloc/stralloc_diff.c ファイルの表示

@@ -7,7 +7,7 @@ extern int stralloc_diff(const stralloc* a,const stralloc* b) {
register int j;
for (i=0;;++i) {
if (i==a->len) return i==b->len?0:-1; if (i==b->len) return 1;
if ((j=(a->s[i]-b->s[i]))) return j;
if ((j=((unsigned char)(a->s[i])-(unsigned char)(b->s[i])))) return j;
}
return j;
}


+ 1
- 1
stralloc/stralloc_diffs.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_diffs \- check if string is prefix of stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_diffs\fP(stralloc* \fIa\fR,const unsigned char* \fIb\fR);
int \fBstralloc_diffs\fP(stralloc* \fIa\fR,const char* \fIb\fR);
.SH DESCRIPTION
stralloc_diffs returns negative, 0, or positive, depending on whether
the \\0-terminated string in \fIa\fR, without


+ 2
- 2
stralloc/stralloc_diffs.c ファイルの表示

@@ -2,12 +2,12 @@
#include "byte.h"
#include "str.h"

extern int stralloc_diffs(const stralloc* a,const unsigned char* b) {
extern int stralloc_diffs(const stralloc* a,const char* b) {
register unsigned long int i;
register int j;
for (i=0;;++i) {
if (i==a->len) return (!b[i])?0:-1; if (!b[i]) return 1;
if ((j=(a->s[i]-b[i]))) return j;
if ((j=((unsigned char)(a->s[i])-(unsigned char)(b[i])))) return j;
}
return j;
}


+ 1
- 1
stralloc/stralloc_starts.3 ファイルの表示

@@ -4,7 +4,7 @@ stralloc_starts \- check if string is prefix of stralloc
.SH SYNTAX
.B #include <stralloc.h>

int \fBstralloc_starts\fP(stralloc* \fIsa\fR,const unsigned char* \fIin\fR);
int \fBstralloc_starts\fP(stralloc* \fIsa\fR,const char* \fIin\fR);
.SH DESCRIPTION
stralloc_starts returns 1 if the \\0-terminated string in \fIin\fR, without
the terminating \\0, is a prefix of the string stored in \fIsa\fR. Otherwise


+ 1
- 1
stralloc/stralloc_starts.c ファイルの表示

@@ -2,7 +2,7 @@
#include "byte.h"
#include "str.h"

extern int stralloc_starts(stralloc *sa,const unsigned char *in) {
extern int stralloc_starts(stralloc *sa,const char *in) {
register unsigned long int len=str_len(in);
return (len<=sa->len && !byte_diff(sa->s,len,in));
}


+ 8
- 1
t.c ファイルの表示

@@ -26,6 +26,9 @@
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")

int64 writecb(int64 fd,const void* buf,uint64 n) {
(void)fd;
(void)buf;
(void)n;
#if 0
int r;
int todo=n>=65536?65536:n;
@@ -37,6 +40,8 @@ int64 writecb(int64 fd,const void* buf,uint64 n) {
}

int main(int argc,char* argv[]) {
(void)argc;
(void)argv;
#if 0
io_batch* b=iob_new(1234);
int64 fd=open("t.c",0);
@@ -312,7 +317,7 @@ int main(int argc,char* argv[]) {
rdtscl(c);
printf("%lu %lu\n",b-a,c-b);
#endif
#if 1
#if 0
unsigned long size;
char* buf=mmap_read(argv[1],&size);
if (buf) {
@@ -323,6 +328,8 @@ int main(int argc,char* argv[]) {
write(1,tmp,x);
}
#endif
printf("%d %d\n",strcmp("foo","bar"),str_diff("foo","bar"));
printf("%d %d\n",strcmp("foo","üar"),str_diff("foo","üar"));
return 0;
}


読み込み中…
キャンセル
保存