]> mj.ucw.cz Git - libucw.git/commitdiff
Libucw: Change sh_ prefix to ucw_.
authorMichal Vaner <vorner@ucw.cz>
Sat, 19 Jul 2008 20:22:20 +0000 (22:22 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 19 Jul 2008 21:55:51 +0000 (23:55 +0200)
And update all uses across the tree.

Macros:
sh_fdatasync -> ucw_fdatasync
sh_fstat -> ucw_fstat
sh_ftruncate -> ucw_ftruncate
sh_mmap -> ucw_mmap
sh_open -> ucw_open
sh_pread -> ucw_pread
sh_pwrite -> ucw_pwrite
sh_seek -> ucw_seek
sh_stat -> ucw_stat

Functions:
sh_file_size -> ucw_file_size

File types:
sh_off_t -> ucw_off_t
sh_sighandler_t -> ucw_sighandler_t
sh_stat_t -> ucw_stat_t
sh_time_t -> ucw_time_t

Internals:
sh_getopt -> ucw_getopt
sh_getopt_long -> ucw_getopt_long
sh_getopt_longonly -> ucw_getopt_longonly
sh_optarg -> ucw_optarg
sh_opterr -> ucw_opterr
sh_optind -> ucw_optind
sh_optopt -> ucw_optopt
sh_xfree -> ucw_xfree
sh_xmalloc -> ucw_xmalloc
sh_xrealloc -> ucw_xrealloc

31 files changed:
debug/sorter/radix-asio-test.c
debug/sorter/radix-file-test.c
images/io-libmagick.c
ucw/config.h
ucw/fastbuf.c
ucw/fastbuf.h
ucw/fb-atomic.c
ucw/fb-buffer.c
ucw/fb-direct.c
ucw/fb-file.c
ucw/fb-grow.c
ucw/fb-mem.c
ucw/fb-mmap.c
ucw/fb-param.c
ucw/fb-temp.c
ucw/getopt/getopt-sh.h
ucw/lfs-test.c
ucw/lfs.h
ucw/lib.h
ucw/lizard-safe.c
ucw/log-file.c
ucw/mainloop.c
ucw/mainloop.h
ucw/partmap.c
ucw/partmap.h
ucw/qache.c
ucw/sighandler.c
ucw/sorter/common.h
ucw/sorter/govern.c
ucw/sorter/sbuck.c
ucw/threads.h

index f288c3be43a851bb44240f7aaab473774296ce14..168f6ff6b4f0b982a3cb2ce434ee2c6bd5989aae 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, char **argv)
 
 #ifdef COPY
   msg(L_INFO, "Creating input file");
-  int in_fd = sh_open("tmp/ft-in", O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
+  int in_fd = ucw_open("tmp/ft-in", O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
   ASSERT(in_fd >= 0);
   ASSERT(!(total_size % bufsize));
   P_INIT;
@@ -85,7 +85,7 @@ int main(int argc, char **argv)
   for (uns i=0; i<files; i++)
     {
       sprintf(name[i], "tmp/ft-%d", i);
-      fd[i] = sh_open(name[i], O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
+      fd[i] = ucw_open(name[i], O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
       if (fd[i] < 0)
        die("Cannot create %s: %m", name[i]);
     }
index 6d9de8ebf2926515d50b072833f0869b666ce4fe..46d1bb4c94dbfe897a9ef4c9039e54ec6610fee2 100644 (file)
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
 
 #ifdef COPY
   msg(L_INFO, "Creating input file");
-  int in_fd = sh_open("tmp/ft-in", O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
+  int in_fd = ucw_open("tmp/ft-in", O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
   ASSERT(in_fd >= 0);
   ASSERT(!(total_size % xbufsize));
   P_INIT;
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
   for (uns i=0; i<files; i++)
     {
       sprintf(name[i], "tmp/ft-%d", i);
-      fd[i] = sh_open(name[i], O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
+      fd[i] = ucw_open(name[i], O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
       if (fd[i] < 0)
        die("Cannot create %s: %m", name[i]);
       buf[i] = big_alloc(bufsize);
index 1a636b2a29ad7b9c53ec3e91c4fb8db21f7d4f4a..fd9069f349d210297e53853dd9adc034f7a4cb77 100644 (file)
@@ -82,7 +82,7 @@ libmagick_read_header(struct image_io *io)
   DBG("libmagick_read_header()");
 
   /* Read entire stream */
-  sh_off_t file_size = bfilesize(io->fastbuf) - btell(io->fastbuf);
+  ucw_off_t file_size = bfilesize(io->fastbuf) - btell(io->fastbuf);
   if (unlikely(file_size > MAX_FILE_SIZE))
     {
       IMAGE_ERROR(io->context, IMAGE_ERROR_READ_FAILED, "Too long stream.");
index e4c3b33d77f383ac2d89e0f53d5ff2235502ffb4..f03572a5b01e845ca5f66f7f2e643fdc9f1c74ed 100644 (file)
@@ -37,13 +37,13 @@ typedef uint64_t u64;                       /* exactly 64 bits, unsigned */
 typedef int64_t s64;                   /* exactly 64 bits, signed */
 
 typedef unsigned int uns;              /* at least 32 bits */
-typedef u32 sh_time_t;                 /* seconds since UNIX epoch */
+typedef u32 ucw_time_t;                        /* seconds since UNIX epoch */
 typedef s64 timestamp_t;               /* milliseconds since UNIX epoch */
 
 #ifdef CONFIG_LARGE_FILES              /* File positions */
-typedef s64 sh_off_t;
+typedef s64 ucw_off_t;
 #else
-typedef s32 sh_off_t;
+typedef s32 ucw_off_t;
 #endif
 
 #endif
index 3ab8b826898fd3d68465482925576876252856d1..9ba01ef4c6c0126ef24e559f3d28bf8096df0056 100644 (file)
@@ -31,7 +31,7 @@ void bflush(struct fastbuf *f)
     f->bptr = f->bstop = f->buffer;
 }
 
-inline void bsetpos(struct fastbuf *f, sh_off_t pos)
+inline void bsetpos(struct fastbuf *f, ucw_off_t pos)
 {
   /* We can optimize seeks only when reading */
   if (pos >= f->pos - (f->bstop - f->buffer) && pos <= f->pos)
@@ -44,7 +44,7 @@ inline void bsetpos(struct fastbuf *f, sh_off_t pos)
     }
 }
 
-void bseek(struct fastbuf *f, sh_off_t pos, int whence)
+void bseek(struct fastbuf *f, ucw_off_t pos, int whence)
 {
   switch (whence)
     {
@@ -189,16 +189,16 @@ bskip_slow(struct fastbuf *f, uns len)
   return 1;
 }
 
-sh_off_t
+ucw_off_t
 bfilesize(struct fastbuf *f)
 {
   if (!f)
     return 0;
-  sh_off_t pos = btell(f);
+  ucw_off_t pos = btell(f);
   bflush(f);
   if (!f->seek(f, 0, SEEK_END))
     return -1;
-  sh_off_t len = btell(f);
+  ucw_off_t len = btell(f);
   bsetpos(f, pos);
   return len;
 }
index 24a368475bbe1ad58216cc57852ecae5ca119ff2..07e893f17917af5e694b99381a44b99c64a7a4ce 100644 (file)
@@ -64,10 +64,10 @@ struct fastbuf {
   byte *bptr, *bstop;                  /* Access pointers */
   byte *buffer, *bufend;               /* Start and end of the buffer */
   char *name;                          /* File name for error messages */
-  sh_off_t pos;                                /* Position of bstop in the file */
+  ucw_off_t pos;                               /* Position of bstop in the file */
   int (*refill)(struct fastbuf *);     /* Get a buffer with new data */
   void (*spout)(struct fastbuf *);     /* Write buffer data to the file */
-  int (*seek)(struct fastbuf *, sh_off_t, int);  /* Slow path for bseek(), buffer already flushed; returns success */
+  int (*seek)(struct fastbuf *, ucw_off_t, int);  /* Slow path for bseek(), buffer already flushed; returns success */
   void (*close)(struct fastbuf *);     /* Close the stream */
   int (*config)(struct fastbuf *, uns, int);   /* Configure the stream */
   int can_overwrite_buffer;            /* Can the buffer be altered? (see discussion above) 0=never, 1=temporarily, 2=permanently */
@@ -202,12 +202,12 @@ int bconfig(struct fastbuf *f, uns type, int data);
 
 void bclose(struct fastbuf *f);
 void bflush(struct fastbuf *f);
-void bseek(struct fastbuf *f, sh_off_t pos, int whence);
-void bsetpos(struct fastbuf *f, sh_off_t pos);
+void bseek(struct fastbuf *f, ucw_off_t pos, int whence);
+void bsetpos(struct fastbuf *f, ucw_off_t pos);
 void brewind(struct fastbuf *f);
-sh_off_t bfilesize(struct fastbuf *f);         /* -1 if not seekable */
+ucw_off_t bfilesize(struct fastbuf *f);                /* -1 if not seekable */
 
-static inline sh_off_t btell(struct fastbuf *f)
+static inline ucw_off_t btell(struct fastbuf *f)
 {
   return f->pos + (f->bptr - f->bstop);
 }
index c6ab7c1b0fbc56aac1b593ebd3403707990e96b6..b5fb6223a01fec4c5d74554a465cdced73c5f28f 100644 (file)
@@ -117,7 +117,7 @@ fbatomic_open(const char *name, struct fastbuf *master, uns bufsize, int record_
   else
     {
       af = xmalloc_zero(sizeof(*af) + strlen(name));
-      if ((af->fd = sh_open(name, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, 0666)) < 0)
+      if ((af->fd = ucw_open(name, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, 0666)) < 0)
        die("Cannot create %s: %m", name);
       af->use_count = 1;
       af->record_len = record_len;
index 3c377e06aa6d8657d7bcf277ee531bb7cbd66959..7f03f25de2fc02d5d593e403e06836ba16176042 100644 (file)
@@ -20,10 +20,10 @@ fbbuf_refill(struct fastbuf *f UNUSED)
 }
 
 static int
-fbbuf_seek(struct fastbuf *f, sh_off_t pos, int whence)
+fbbuf_seek(struct fastbuf *f, ucw_off_t pos, int whence)
 {
   /* Somebody might want to seek to the end of buffer, try to be nice to him. */
-  sh_off_t len = f->bufend - f->buffer;
+  ucw_off_t len = f->bufend - f->buffer;
   if (whence == SEEK_END)
     pos += len;
   ASSERT(pos >= 0 && pos <= len);
index 1c4409ac3f914899db4abf866f30e365ecfe0553..15a4568ad90f6c925ffe57f3412208ab10c3f7b2 100644 (file)
@@ -190,7 +190,7 @@ fbdir_spout(struct fastbuf *f)
          asio_submit(r);
          asio_sync(F->io_queue);
          DBG("FB-DIRECT: Truncating at %llu", (long long)f->pos);
-         if (sh_ftruncate(F->fd, f->pos) < 0)
+         if (ucw_ftruncate(F->fd, f->pos) < 0)
            die("Error truncating %s: %m", f->name);
        }
       else
@@ -205,7 +205,7 @@ fbdir_spout(struct fastbuf *f)
 }
 
 static int
-fbdir_seek(struct fastbuf *f, sh_off_t pos, int whence)
+fbdir_seek(struct fastbuf *f, ucw_off_t pos, int whence)
 {
   DBG("FB-DIRECT: Seek %llu %d", (long long)pos, whence);
 
@@ -213,7 +213,7 @@ fbdir_seek(struct fastbuf *f, sh_off_t pos, int whence)
     return 1;
 
   fbdir_change_mode(FB_DIRECT(f), M_NULL);                     // Wait for all async requests to finish
-  sh_off_t l = sh_seek(FB_DIRECT(f)->fd, pos, whence);
+  ucw_off_t l = ucw_seek(FB_DIRECT(f)->fd, pos, whence);
   if (l < 0)
     return 0;
   f->pos = l;
index 7e3e73e406be9b8baab351b42d3c9311a21683ce..3eb2996f52e0303fa4defa5f3d1bee8f157a74cf 100644 (file)
@@ -22,7 +22,7 @@ struct fb_file {
   int fd;                              /* File descriptor */
   int is_temp_file;
   int keep_back_buf;                   /* Optimize for backwards reading */
-  sh_off_t wpos;                       /* Real file position */
+  ucw_off_t wpos;                      /* Real file position */
   uns wlen;                            /* Window size */
 };
 #define FB_FILE(f) ((struct fb_file *)(f)->is_fastbuf)
@@ -37,9 +37,9 @@ bfd_refill(struct fastbuf *f)
   /* Forward or no seek */
   if (F->wpos <= f->pos)
     {
-      sh_off_t diff = f->pos - F->wpos;
+      ucw_off_t diff = f->pos - F->wpos;
       /* Formula for long forward seeks (prefer lseek()) */
-      if (diff > ((sh_off_t)blen << 2))
+      if (diff > ((ucw_off_t)blen << 2))
         {
 long_seek:
          f->bptr = f->buffer + back;
@@ -82,11 +82,11 @@ long_seek:
   /* Backwards seek */
   else
     {
-      sh_off_t diff = F->wpos - f->pos;
+      ucw_off_t diff = F->wpos - f->pos;
       /* Formula for long backwards seeks (keep smaller backbuffer than for shorter seeks ) */
-      if (diff > ((sh_off_t)blen << 1))
+      if (diff > ((ucw_off_t)blen << 1))
         {
-         if ((sh_off_t)back > f->pos)
+         if ((ucw_off_t)back > f->pos)
            back = f->pos;
          goto long_seek;
        }
@@ -99,7 +99,7 @@ long_seek:
          return 1;
        }
       back *= 3;
-      if ((sh_off_t)back > f->pos)
+      if ((ucw_off_t)back > f->pos)
        back = f->pos;
       f->bptr = f->buffer + back;
       read_len = blen;
@@ -113,7 +113,7 @@ long_seek:
 seek:
       /* Do lseek() */
       F->wpos = f->pos + (f->buffer - f->bptr);
-      if (sh_seek(F->fd, F->wpos, SEEK_SET) < 0)
+      if (ucw_seek(F->fd, F->wpos, SEEK_SET) < 0)
        die("Error seeking %s: %m", f->name);
     }
   /* Read (part of) buffer */
@@ -148,7 +148,7 @@ static void
 bfd_spout(struct fastbuf *f)
 {
   /* Do delayed lseek() if needed */
-  if (FB_FILE(f)->wpos != f->pos && sh_seek(FB_FILE(f)->fd, f->pos, SEEK_SET) < 0)
+  if (FB_FILE(f)->wpos != f->pos && ucw_seek(FB_FILE(f)->fd, f->pos, SEEK_SET) < 0)
     die("Error seeking %s: %m", f->name);
 
   int l = f->bptr - f->buffer;
@@ -169,10 +169,10 @@ bfd_spout(struct fastbuf *f)
 }
 
 static int
-bfd_seek(struct fastbuf *f, sh_off_t pos, int whence)
+bfd_seek(struct fastbuf *f, ucw_off_t pos, int whence)
 {
   /* Delay the seek for the next refill() or spout() call (if whence != SEEK_END). */
-  sh_off_t l;
+  ucw_off_t l;
   switch (whence)
     {
       case SEEK_SET:
@@ -185,7 +185,7 @@ bfd_seek(struct fastbuf *f, sh_off_t pos, int whence)
        f->pos = l;
        return 1;
       case SEEK_END:
-       l = sh_seek(FB_FILE(f)->fd, pos, SEEK_END);
+       l = ucw_seek(FB_FILE(f)->fd, pos, SEEK_END);
        if (l < 0)
          return 0;
        FB_FILE(f)->wpos = f->pos = l;
index 4d98d3153a69353bf0440be1c334a04477740f77..e1da0107f4bfadc07118b1620603476819d92037 100644 (file)
@@ -47,10 +47,10 @@ fbgrow_spout(struct fastbuf *b)
 }
 
 static int
-fbgrow_seek(struct fastbuf *b, sh_off_t pos, int whence)
+fbgrow_seek(struct fastbuf *b, ucw_off_t pos, int whence)
 {
   ASSERT(FB_GBUF(b)->last_written);    /* Seeks allowed only in read mode */
-  sh_off_t len = FB_GBUF(b)->last_written - b->buffer;
+  ucw_off_t len = FB_GBUF(b)->last_written - b->buffer;
   if (whence == SEEK_END)
     pos += len;
   ASSERT(pos >= 0 && pos <= len);
index 40b9f1e5458034594b18ff1901b3df0c2bf64f23..cddb169a8c690f2c2f29de1cb137b4c12f2514d7 100644 (file)
@@ -20,7 +20,7 @@ struct memstream {
 
 struct msblock {
   struct msblock *next;
-  sh_off_t pos;
+  ucw_off_t pos;
   unsigned size;
   byte data[0];
 };
@@ -96,7 +96,7 @@ fbmem_spout(struct fastbuf *f)
 }
 
 static int
-fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
+fbmem_seek(struct fastbuf *f, ucw_off_t pos, int whence)
 {
   struct memstream *m = FB_MEM(f)->stream;
   struct msblock *b;
@@ -110,7 +110,7 @@ fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
   /* Yes, this is linear. But considering the average number of buckets, it doesn't matter. */
   for (b=m->first; b; b=b->next)
     {
-      if (pos <= b->pos + (sh_off_t)b->size) /* <=, because we need to be able to seek just after file end */
+      if (pos <= b->pos + (ucw_off_t)b->size) /* <=, because we need to be able to seek just after file end */
        {
          f->buffer = b->data;
          f->bptr = b->data + (pos - b->pos);
index 0932814f616a402212fde6866979134f1be3d950..afd0bb12621352f854ae1819914b0dde15a8df8a 100644 (file)
@@ -39,9 +39,9 @@ struct fb_mmap {
   struct fastbuf fb;
   int fd;
   int is_temp_file;
-  sh_off_t file_size;
-  sh_off_t file_extend;
-  sh_off_t window_pos;
+  ucw_off_t file_size;
+  ucw_off_t file_extend;
+  ucw_off_t window_pos;
   uns window_size;
   int mode;
 };
@@ -51,8 +51,8 @@ static void
 bfmm_map_window(struct fastbuf *f)
 {
   struct fb_mmap *F = FB_MMAP(f);
-  sh_off_t pos0 = f->pos & ~(sh_off_t)(CPU_PAGE_SIZE-1);
-  int l = MIN((sh_off_t)mmap_window_size, F->file_extend - pos0);
+  ucw_off_t pos0 = f->pos & ~(ucw_off_t)(CPU_PAGE_SIZE-1);
+  int l = MIN((ucw_off_t)mmap_window_size, F->file_extend - pos0);
   uns ll = ALIGN_TO(l, CPU_PAGE_SIZE);
   int prot = ((F->mode & O_ACCMODE) == O_RDONLY) ? PROT_READ : (PROT_READ | PROT_WRITE);
 
@@ -64,9 +64,9 @@ bfmm_map_window(struct fastbuf *f)
     }
   F->window_size = ll;
   if (!f->buffer)
-    f->buffer = sh_mmap(NULL, ll, prot, MAP_SHARED, F->fd, pos0);
+    f->buffer = ucw_mmap(NULL, ll, prot, MAP_SHARED, F->fd, pos0);
   else
-    f->buffer = sh_mmap(f->buffer, ll, prot, MAP_SHARED | MAP_FIXED, F->fd, pos0);
+    f->buffer = ucw_mmap(f->buffer, ll, prot, MAP_SHARED | MAP_FIXED, F->fd, pos0);
   if (f->buffer == (byte *) MAP_FAILED)
     die("mmap(%s): %m", f->name);
 #ifdef MADV_SEQUENTIAL
@@ -101,7 +101,7 @@ static void
 bfmm_spout(struct fastbuf *f)
 {
   struct fb_mmap *F = FB_MMAP(f);
-  sh_off_t end = f->pos + (f->bptr - f->bstop);
+  ucw_off_t end = f->pos + (f->bptr - f->bstop);
 
   DBG("Spout <- %p %p %p %p", f->buffer, f->bptr, f->bstop, f->bufend);
   if (end > F->file_size)
@@ -111,8 +111,8 @@ bfmm_spout(struct fastbuf *f)
   f->pos = end;
   if (f->pos >= F->file_extend)
     {
-      F->file_extend = ALIGN_TO(F->file_extend + mmap_extend_size, (sh_off_t)CPU_PAGE_SIZE);
-      if (sh_ftruncate(F->fd, F->file_extend))
+      F->file_extend = ALIGN_TO(F->file_extend + mmap_extend_size, (ucw_off_t)CPU_PAGE_SIZE);
+      if (ucw_ftruncate(F->fd, F->file_extend))
        die("ftruncate(%s): %m", f->name);
     }
   bfmm_map_window(f);
@@ -121,7 +121,7 @@ bfmm_spout(struct fastbuf *f)
 }
 
 static int
-bfmm_seek(struct fastbuf *f, sh_off_t pos, int whence)
+bfmm_seek(struct fastbuf *f, ucw_off_t pos, int whence)
 {
   if (whence == SEEK_END)
     pos += FB_MMAP(f)->file_size;
@@ -142,7 +142,7 @@ bfmm_close(struct fastbuf *f)
   if (f->buffer)
     munmap(f->buffer, F->window_size);
   if (F->file_extend > F->file_size &&
-      sh_ftruncate(F->fd, F->file_size))
+      ucw_ftruncate(F->fd, F->file_size))
     die("ftruncate(%s): %m", f->name);
   bclose_file_helper(f, F->fd, F->is_temp_file);
   xfree(f);
@@ -175,7 +175,7 @@ bfmmopen_internal(int fd, const char *name, uns mode)
   f->name = (byte *)(F+1);
   memcpy(f->name, name, namelen);
   F->fd = fd;
-  F->file_extend = F->file_size = sh_seek(fd, 0, SEEK_END);
+  F->file_extend = F->file_size = ucw_seek(fd, 0, SEEK_END);
   if (F->file_size < 0)
     die("seek(%s): %m", name);
   if (mode & O_APPEND)
index 0ad576db8b89110a22c3d7ae34c8199d657d69c4..dafd23edde9f05c026621f8dfe18d7fa5400da11 100644 (file)
@@ -108,7 +108,7 @@ bopen_file_internal(const char *name, int mode, struct fb_params *params, int tr
 #endif
   if (params->type == FB_MMAP && (mode & O_ACCMODE) == O_WRONLY)
     mode = (mode & ~O_ACCMODE) | O_RDWR;
-  int fd = sh_open(name, mode, 0666);
+  int fd = ucw_open(name, mode, 0666);
   if (fd < 0)
     if (try)
       return NULL;
index 4d924d504928fc10b0a9c3d83947f8c3349dca6d..e1d3494dc45381c799bef9ebbbe12cccdbca8f03 100644 (file)
@@ -95,8 +95,8 @@ open_tmp(char *name_buf, int open_flags, int mode)
   int create_flags, fd, retry = 10;
   do
     {
-      temp_file_name(name_buf, &create_flags);
-      fd = open(name_buf, open_flags | create_flags, mode);
+      temp_file_name(name, &create_mode);
+      fd = ucw_open(name, flags | create_mode, mode);
     }
   while (fd < 0 && errno == EEXIST && retry --);
   if (fd < 0)
index a1b24fbc621b266625ca695bcaf0aaa122edb4e1..868ffce0774b0d2e8a36dba2e660b5b6b9aea34f 100644 (file)
@@ -1,13 +1,13 @@
 #ifndef _UCW_GETOPT_GETOPT_SH_H
 #define _UCW_GETOPT_GETOPT_SH_H
 
-#define getopt sh_getopt
-#define getopt_long sh_getopt_long
-#define getopt_long_only sh_getopt_longonly
-#define optarg sh_optarg
-#define optind sh_optind
-#define opterr sh_opterr
-#define optopt sh_optopt
+#define getopt ucw_getopt
+#define getopt_long ucw_getopt_long
+#define getopt_long_only ucw_getopt_longonly
+#define optarg ucw_optarg
+#define optind ucw_optind
+#define opterr ucw_opterr
+#define optopt ucw_optopt
 
 #include "ucw/getopt/getopt.h"
 
index 9646c3651a66a661d6bc05b1dcac4fe486b6107b..07596cbd9cb2874d020f8028a1192d52876679f0 100644 (file)
@@ -45,7 +45,7 @@ int main(void)
        for (i=0; i<TESTS; i++)
        {
                uns idx = random()%COUNT;
-               sh_off_t ofs = idx*BLOCK;
+               ucw_off_t ofs = idx*BLOCK;
                bseek(b, ofs, SEEK_SET);
                bread(b, block, BLOCK);
                if (block[17] != (idx & 0xff))
index ede41268691578370d490c229013ac6adc3cd250..593dcf7d727c196e8587ae7162263061fd610d9a 100644 (file)
--- a/ucw/lfs.h
+++ b/ucw/lfs.h
 
 #ifdef CONFIG_LFS
 
-#define sh_open open64
-#define sh_seek lseek64
-#define sh_pread pread64
-#define sh_pwrite pwrite64
-#define sh_ftruncate ftruncate64
-#define sh_mmap(a,l,p,f,d,o) mmap64(a,l,p,f,d,o)
-#define sh_pread pread64
-#define sh_pwrite pwrite64
-#define sh_stat stat64
-#define sh_fstat fstat64
-typedef struct stat64 sh_stat_t;
+#define ucw_open open64
+#define ucw_seek lseek64
+#define ucw_pread pread64
+#define ucw_pwrite pwrite64
+#define ucw_ftruncate ftruncate64
+#define ucw_mmap(a,l,p,f,d,o) mmap64(a,l,p,f,d,o)
+#define ucw_pread pread64
+#define ucw_pwrite pwrite64
+#define ucw_stat stat64
+#define ucw_fstat fstat64
+typedef struct stat64 ucw_stat_t;
 
 #else  /* !CONFIG_LFS */
 
-#define sh_open open
-#define sh_seek(f,o,w) lseek(f,o,w)
-#define sh_ftruncate(f,o) ftruncate(f,o)
-#define sh_mmap(a,l,p,f,d,o) mmap(a,l,p,f,d,o)
-#define sh_pread pread
-#define sh_pwrite pwrite
-#define sh_stat stat
-#define sh_fstat fstat
-typedef struct stat sh_stat_t;
+#define ucw_open open
+#define ucw_seek(f,o,w) lseek(f,o,w)
+#define ucw_ftruncate(f,o) ftruncate(f,o)
+#define ucw_mmap(a,l,p,f,d,o) mmap(a,l,p,f,d,o)
+#define ucw_pread pread
+#define ucw_pwrite pwrite
+#define ucw_stat stat
+#define ucw_fstat fstat
+typedef struct stat ucw_stat_t;
 
 #endif /* !CONFIG_LFS */
 
 #if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0)
-#define sh_fdatasync fdatasync
+#define ucw_fdatasync fdatasync
 #else
-#define sh_fdatasync fsync
+#define ucw_fdatasync fsync
 #endif
 
 #define HAVE_PREAD
 
-static inline sh_off_t
-sh_file_size(const char *name)
+static inline ucw_off_t
+ucw_file_size(const char *name)
 {
-  int fd = sh_open(name, O_RDONLY);
+  int fd = ucw_open(name, O_RDONLY);
   if (fd < 0)
     die("Cannot open %s: %m", name);
-  sh_off_t len = sh_seek(fd, 0, SEEK_END);
+  ucw_off_t len = ucw_seek(fd, 0, SEEK_END);
   close(fd);
   return len;
 }
index 904cadeee5a4b01e681a8f3367bb380f4bc6e4b1..0dad3777b67a58815b26d2bc3ee16b2baaac8868 100644 (file)
--- a/ucw/lib.h
+++ b/ucw/lib.h
@@ -132,9 +132,9 @@ void assert_failed_noinfo(void) NONRET;
 
 /* Memory allocation */
 
-#define xmalloc sh_xmalloc
-#define xrealloc sh_xrealloc
-#define xfree sh_xfree
+#define xmalloc ucw_xmalloc
+#define xrealloc ucw_xrealloc
+#define xfree ucw_xfree
 
 /*
  * Unfortunately, several libraries we might want to link to define
@@ -213,11 +213,11 @@ void sync_dir(const char *name);
 
 /* sighandler.c */
 
-typedef int (*sh_sighandler_t)(int);   // gets signum, returns nonzero if abort() should be called
+typedef int (*ucw_sighandler_t)(int);  // gets signum, returns nonzero if abort() should be called
 
 void handle_signal(int signum);
 void unhandle_signal(int signum);
-sh_sighandler_t set_signal_handler(int signum, sh_sighandler_t new);
+ucw_sighandler_t set_signal_handler(int signum, ucw_sighandler_t new);
 
 /* bigalloc.c */
 
index 96eeb4385cde6df9cca0de3b8b513bbb7e57a15f..ba7d8df34cdb05a9602735e2ea0aea266b3a8be1 100644 (file)
@@ -79,7 +79,7 @@ lizard_decompress_safe(const byte *in, struct lizard_buffer *buf, uns expected_l
   uns lock_offset = ALIGN_TO(expected_length + 3, CPU_PAGE_SIZE);      // +3 due to the unaligned access
   if (lock_offset > buf->len)
     lizard_realloc(buf, lock_offset);
-  volatile sh_sighandler_t old_handler = set_signal_handler(SIGSEGV, sigsegv_handler);
+  volatile ucw_sighandler_t old_handler = set_signal_handler(SIGSEGV, sigsegv_handler);
   byte *ptr;
   if (!setjmp(safe_decompress_jump))
   {
index 7bfeaa6822280946c46f07556e4c91be521cfb5b..6ac07823894f23a324eb80dec9e2906b0d0f9055 100644 (file)
@@ -40,7 +40,7 @@ do_log_switch(struct tm *tm)
   if (strcmp(name, log_filename))
     {
       strcpy(log_filename, name);
-      fd = sh_open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
+      fd = ucw_open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
       if (fd < 0)
        die("Unable to open log file %s: %m", name);
       dup2(fd, 2);
index f7994748dac991d6a20fd0ae4dfb5a4d6f7b34db..4c8e2cd43bd3835330c81f8a7881f6de4d9f45ca 100644 (file)
@@ -24,7 +24,7 @@
 #include <sys/time.h>
 
 timestamp_t main_now;
-sh_time_t main_now_seconds;
+ucw_time_t main_now_seconds;
 uns main_shutdown;
 
 clist main_timer_list, main_file_list, main_hook_list, main_process_list;
index e4992bc14e7e8415dfd31828ccb2af0fde3ea8c2..0c5e90fbdd96d2b6aa9fe8ab8c4544ddb30141c9 100644 (file)
@@ -13,7 +13,7 @@
 #include "ucw/clists.h"
 
 extern timestamp_t main_now;                   /* Current time in milliseconds since UNIX epoch */
-extern sh_time_t main_now_seconds;             /* Current time in seconds since the epoch */
+extern ucw_time_t main_now_seconds;            /* Current time in seconds since the epoch */
 extern uns main_shutdown;
 extern clist main_timer_list, main_file_list, main_hook_list, main_process_list;
 
index c2b90f8f1ac1d80cf7d6df9acae1f426f9dbe1b8..ed74df363219608c6c58b60e0da0f047aaa85c28 100644 (file)
@@ -34,10 +34,10 @@ partmap_open(char *name, int writeable)
 {
   struct partmap *p = xmalloc_zero(sizeof(struct partmap));
 
-  p->fd = sh_open(name, writeable ? O_RDWR : O_RDONLY);
+  p->fd = ucw_open(name, writeable ? O_RDWR : O_RDONLY);
   if (p->fd < 0)
     die("open(%s): %m", name);
-  if ((p->file_size = sh_seek(p->fd, 0, SEEK_END)) < 0)
+  if ((p->file_size = ucw_seek(p->fd, 0, SEEK_END)) < 0)
     die("lseek(%s): %m", name);
   p->writeable = writeable;
 #ifdef CONFIG_PARTMAP_IS_MMAP
@@ -46,7 +46,7 @@ partmap_open(char *name, int writeable)
   return p;
 }
 
-sh_off_t
+ucw_off_t
 partmap_size(struct partmap *p)
 {
   return p->file_size;
@@ -62,18 +62,18 @@ partmap_close(struct partmap *p)
 }
 
 void
-partmap_load(struct partmap *p, sh_off_t start, uns size)
+partmap_load(struct partmap *p, ucw_off_t start, uns size)
 {
   if (p->start_map)
     munmap(p->start_map, p->end_off - p->start_off);
-  sh_off_t end = start + size;
-  sh_off_t win_start = start/CPU_PAGE_SIZE * CPU_PAGE_SIZE;
+  ucw_off_t end = start + size;
+  ucw_off_t win_start = start/CPU_PAGE_SIZE * CPU_PAGE_SIZE;
   size_t win_len = PARTMAP_WINDOW;
-  if ((sh_off_t) (win_start+win_len) > p->file_size)
+  if ((ucw_off_t) (win_start+win_len) > p->file_size)
     win_len = ALIGN_TO(p->file_size - win_start, CPU_PAGE_SIZE);
-  if ((sh_off_t) (win_start+win_len) < end)
+  if ((ucw_off_t) (win_start+win_len) < end)
     die("partmap_map: Window is too small for mapping %d bytes", size);
-  p->start_map = sh_mmap(NULL, win_len, p->writeable ? (PROT_READ | PROT_WRITE) : PROT_READ, MAP_SHARED, p->fd, win_start);
+  p->start_map = ucw_mmap(NULL, win_len, p->writeable ? (PROT_READ | PROT_WRITE) : PROT_READ, MAP_SHARED, p->fd, win_start);
   if (p->start_map == MAP_FAILED)
     die("mmap failed at position %lld: %m", (long long)win_start);
   p->start_off = win_start;
index 985b36267ade51bfa2def9893fd5b985b8dd72e9..1e5d1d5fbf8f0c2ecddca0230aa6f93789a66778 100644 (file)
 
 struct partmap {
   int fd;
-  sh_off_t file_size;
-  sh_off_t start_off, end_off;
+  ucw_off_t file_size;
+  ucw_off_t start_off, end_off;
   byte *start_map;
   int writeable;
 };
 
 struct partmap *partmap_open(char *name, int writeable);
 void partmap_close(struct partmap *p);
-sh_off_t partmap_size(struct partmap *p);
-void partmap_load(struct partmap *p, sh_off_t start, uns size);
+ucw_off_t partmap_size(struct partmap *p);
+void partmap_load(struct partmap *p, ucw_off_t start, uns size);
 
 static inline void *
-partmap_map(struct partmap *p, sh_off_t start, uns size UNUSED)
+partmap_map(struct partmap *p, ucw_off_t start, uns size UNUSED)
 {
 #ifndef CONFIG_PARTMAP_IS_MMAP
-  if (unlikely(!p->start_map || start < p->start_off || (sh_off_t) (start+size) > p->end_off))
+  if (unlikely(!p->start_map || start < p->start_off || (ucw_off_t) (start+size) > p->end_off))
     partmap_load(p, start, size);
 #endif
   return p->start_map + (start - p->start_off);
 }
 
 static inline void *
-partmap_map_forward(struct partmap *p, sh_off_t start, uns size UNUSED)
+partmap_map_forward(struct partmap *p, ucw_off_t start, uns size UNUSED)
 {
 #ifndef CONFIG_PARTMAP_IS_MMAP
-  if (unlikely((sh_off_t) (start+size) > p->end_off))
+  if (unlikely((ucw_off_t) (start+size) > p->end_off))
     partmap_load(p, start, size);
 #endif
   return p->start_map + (start - p->start_off);
index 26b178cb38f5e92718ad35b6d779f3a9ce26aa54..af678a5bbed6f2e2a8816c517a6ed16687f41112 100644 (file)
@@ -331,7 +331,7 @@ qache_create(struct qache *q, struct qache_params *par)
   bwrite(fb, &h, sizeof(h));
 
   /* Entry #0: heads of all lists */
-  ASSERT(btell(fb) == (sh_off_t)h.entry_table_start);
+  ASSERT(btell(fb) == (ucw_off_t)h.entry_table_start);
   struct qache_entry ent;
   bzero(&ent, sizeof(ent));
   ent.first_data_block = h.first_data_block;
@@ -349,18 +349,18 @@ qache_create(struct qache *q, struct qache_params *par)
     }
 
   /* The hash table */
-  ASSERT(btell(fb) == (sh_off_t)h.hash_table_start);
+  ASSERT(btell(fb) == (ucw_off_t)h.hash_table_start);
   for (uns i=0; i<h.hash_size; i++)
     bputl(fb, 0);
 
   /* The next pointers */
-  ASSERT(btell(fb) == (sh_off_t)h.next_table_start);
+  ASSERT(btell(fb) == (ucw_off_t)h.next_table_start);
   for (uns i=0; i<h.num_blocks; i++)
     bputl(fb, (i < h.first_data_block || i == h.num_blocks-1) ? 0 : i+1);
 
   /* Padding */
-  ASSERT(btell(fb) <= (sh_off_t)(h.first_data_block << h.block_shift));
-  while (btell(fb) < (sh_off_t)(h.first_data_block << h.block_shift))
+  ASSERT(btell(fb) <= (ucw_off_t)(h.first_data_block << h.block_shift));
+  while (btell(fb) < (ucw_off_t)(h.first_data_block << h.block_shift))
     bputc(fb, 0);
 
   /* Data blocks */
@@ -368,7 +368,7 @@ qache_create(struct qache *q, struct qache_params *par)
     for (uns j=0; j<h.block_size; j+=4)
       bputl(fb, 0);
 
-  ASSERT(btell(fb) == (sh_off_t)par->cache_size);
+  ASSERT(btell(fb) == (ucw_off_t)par->cache_size);
   bclose(fb);
   msg(L_INFO, "Cache %s: created (%d bytes, %d slots, %d buckets)", q->file_name, par->cache_size, h.max_entries, h.hash_size);
 
index 3f7daf2213496bb2be0f12bad93709166e25cbec..cfd09c0b3a6aaf2993d63176f36a76be6ad595cf 100644 (file)
@@ -52,13 +52,13 @@ unhandle_signal(int signum)
   ucwlib_unlock();
 }
 
-sh_sighandler_t
-set_signal_handler(int signum, sh_sighandler_t new)
+ucw_sighandler_t
+set_signal_handler(int signum, ucw_sighandler_t new)
 {
   struct ucwlib_context *ctx = ucwlib_thread_context();
   if (!ctx->signal_handlers)
-    ctx->signal_handlers = xmalloc_zero(NSIG * sizeof(sh_sighandler_t));
-  sh_sighandler_t old = ctx->signal_handlers[signum];
+    ctx->signal_handlers = xmalloc_zero(NSIG * sizeof(ucw_sighandler_t));
+  ucw_sighandler_t old = ctx->signal_handlers[signum];
   ctx->signal_handlers[signum] = new;
   return old;
 }
index b577f3dcc10b543bdf65d43b359e1eabf2835866..a91050b3c646dd016b5e6af1a987300cf6e51fa4 100644 (file)
@@ -114,7 +114,7 @@ struct sort_bucket *sbuck_new(struct sort_context *ctx);
 void sbuck_drop(struct sort_bucket *b);
 int sbuck_have(struct sort_bucket *b);
 int sbuck_has_file(struct sort_bucket *b);
-sh_off_t sbuck_size(struct sort_bucket *b);
+ucw_off_t sbuck_size(struct sort_bucket *b);
 struct fastbuf *sbuck_read(struct sort_bucket *b);
 struct fastbuf *sbuck_write(struct sort_bucket *b);
 void sbuck_swap_out(struct sort_bucket *b);
index c199381c078016cf242841fb976f41707b461b8a..b54d0786b3c03a550ad788c9aacebd0612c2466a 100644 (file)
@@ -61,7 +61,7 @@ sorter_presort(struct sort_context *ctx, struct sort_bucket *in, struct sort_buc
 }
 
 static struct sort_bucket *
-sbuck_join_to(struct sort_bucket *b, sh_off_t *sizep)
+sbuck_join_to(struct sort_bucket *b, ucw_off_t *sizep)
 {
   if (sorter_debug & SORT_DEBUG_NO_JOIN)
     return NULL;
@@ -74,8 +74,8 @@ sbuck_join_to(struct sort_bucket *b, sh_off_t *sizep)
   return out;
 }
 
-static sh_off_t
-sbuck_ins_or_join(struct sort_bucket *b, cnode *list_pos, struct sort_bucket *join, sh_off_t join_size)
+static ucw_off_t
+sbuck_ins_or_join(struct sort_bucket *b, cnode *list_pos, struct sort_bucket *join, ucw_off_t join_size)
 {
   if (join && join->runs >= 2)
     {
@@ -124,7 +124,7 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b)
 {
   struct sort_bucket *ins[3] = { NULL }, *outs[3] = { NULL };
   cnode *list_pos = b->n.prev;
-  sh_off_t join_size;
+  ucw_off_t join_size;
   struct sort_bucket *join = sbuck_join_to(b, &join_size);
 
   if (!(sorter_debug & SORT_DEBUG_NO_PRESORT) || (b->flags & SBF_CUSTOM_PRESORT))
@@ -135,7 +135,7 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b)
       if (!sorter_presort(ctx, b, ins[0], join ? : ins[0]))
        {
          sorter_stop_timer(ctx, &ctx->total_pre_time);
-         sh_off_t size = sbuck_ins_or_join(ins[0], list_pos, join, join_size);
+         ucw_off_t size = sbuck_ins_or_join(ins[0], list_pos, join, join_size);
          SORT_XTRACE(((b->flags & SBF_SOURCE) ? 1 : 3), "Sorted in memory (%s, %dMB/s)", stk_fsize(size), sorter_speed(ctx, size));
          sbuck_drop(b);
          return;
@@ -169,7 +169,7 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b)
        outs[0] = join;
        outs[1] = NULL;
        ctx->twoway_merge(ctx, ins, outs);
-       sh_off_t size = sbuck_ins_or_join(NULL, NULL, join, join_size);
+       ucw_off_t size = sbuck_ins_or_join(NULL, NULL, join, join_size);
        sorter_stop_timer(ctx, &ctx->total_ext_time);
        SORT_TRACE("Mergesort pass %d (final run, %s, %dMB/s)", pass, stk_fsize(size), sorter_speed(ctx, size));
        sbuck_drop(ins[0]);
@@ -199,7 +199,7 @@ sorter_multiway(struct sort_context *ctx, struct sort_bucket *b)
 {
   clist parts;
   cnode *list_pos = b->n.prev;
-  sh_off_t join_size;
+  ucw_off_t join_size;
   struct sort_bucket *join = sbuck_join_to(b, &join_size);
   uns trace_level = (b->flags & SBF_SOURCE) ? 1 : 3;
 
@@ -231,7 +231,7 @@ sorter_multiway(struct sort_context *ctx, struct sort_bucket *b)
 
   if (part_cnt <= 1)
     {
-      sh_off_t size = sbuck_ins_or_join(clist_head(&parts), list_pos, (part_cnt ? NULL : join), join_size);
+      ucw_off_t size = sbuck_ins_or_join(clist_head(&parts), list_pos, (part_cnt ? NULL : join), join_size);
       SORT_XTRACE(trace_level, "Sorted in memory (%s, %dMB/s)", stk_fsize(size), sorter_speed(ctx, size));
       return;
     }
@@ -267,7 +267,7 @@ sorter_multiway(struct sort_context *ctx, struct sort_bucket *b)
 
       if (clist_empty(&parts))
        {
-         sh_off_t size = sbuck_ins_or_join((join ? NULL : out), list_pos, join, join_size);
+         ucw_off_t size = sbuck_ins_or_join((join ? NULL : out), list_pos, join, join_size);
          SORT_TRACE("Multi-way merge completed (%d ways, %s, %dMB/s)", n, stk_fsize(size), sorter_speed(ctx, size));
          return;
        }
index 7ec26785fbb82acd5cb40555fb1224a48c1536d5..875b0e1f14c17f2b4d06f42adf347be615f11099 100644 (file)
@@ -43,7 +43,7 @@ sbuck_drop(struct sort_bucket *b)
     }
 }
 
-sh_off_t
+ucw_off_t
 sbuck_size(struct sort_bucket *b)
 {
   if ((b->flags & SBF_OPEN_WRITE) && !(b->flags & SBF_SWAPPED_OUT))
index c70354fb71dafb8ce8e6418de946dd45d8b1624d..5644d152ce9b6fe1fb71ce29c5de940a0e2f25da 100644 (file)
@@ -16,7 +16,7 @@ struct ucwlib_context {
   int thread_id;                       // Thread ID (either kernel tid or a counter)
   int temp_counter;                    // Counter for fb-temp.c
   struct asio_queue *io_queue;         // Async I/O queue for fb-direct.c
-  sh_sighandler_t *signal_handlers;    // Signal handlers for sighandler.c
+  ucw_sighandler_t *signal_handlers;   // Signal handlers for sighandler.c
 };
 
 struct ucwlib_context *ucwlib_thread_context(void);