RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   19-Jun-2017 03:23:44
  Branch: rpm-5_4                          Handle: 2017061901234400

  Modified files:           (Branch: rpm-5_4)
    rpm/rpmio               teio.c

  Log:
    - rpmeio: WIP.

  Summary:
    Revision    Changes     Path
    1.1.2.6     +139 -34    rpm/rpmio/teio.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/teio.c
  ============================================================================
  $ cvs diff -u -r1.1.2.5 -r1.1.2.6 teio.c
  --- rpm/rpmio/teio.c  18 Jun 2017 09:44:14 -0000      1.1.2.5
  +++ rpm/rpmio/teio.c  19 Jun 2017 01:23:44 -0000      1.1.2.6
  @@ -310,7 +310,7 @@
        /* __NR_getitimer 36 */
       "int getitimer(int which, struct itimerval *value);",
        /* __NR_alarm 37 */
  -    "unsigned int alarm(unsigned int seconds);",
  +    "unsigned alarm(unsigned seconds);",
        /* __NR_setitimer 38 */
       "int setitimer(int which, const struct itimerval *restrict value, struct 
itimerval *restrict ovalue);",
        /* __NR_getpid 39 */
  @@ -392,7 +392,7 @@
        /* __NR_ftruncate 77 */
       "int ftruncate(int fdno, off_t length);",
        /* __NR_getdents 78 */
  -    "int getdents(unsigned int fdno, struct linux_dirent *dirp, unsigned int 
count);",
  +    "int getdents(int fdno, struct linux_dirent *dirp, unsigned count);",
        /* __NR_getcwd 79 */
       "char *getcwd(char *buf, size_t size);",
        /* __NR_chdir 80 */
  @@ -509,7 +509,7 @@
        /* __NR_fstatfs 138 */
       "int fstatfs(int fdno, struct statfs *buf);",
        /* __NR_sysfs 139 */
  -    "int sysfs(int option, unsigned int fs_index, char *buf);",
  +    "int sysfs(int option, unsigned fs_index, char *buf);",
        /* __NR_getpriority 140 */
       "int getpriority(int which, id_t who);",
        /* __NR_setpriority 141 */
  @@ -658,7 +658,7 @@
        /* __NR_remap_file_pages 216 */
       "int remap_file_pages(void *addr, size_t size, int prot, size_t pgoff, 
int flags);",
        /* __NR_getdents64 217 */
  -    "int getdents64(unsigned int fdno, struct linux_dirent64 *dirp, unsigned 
int count);",
  +    "int getdents64(int fdno, struct linux_dirent64 *dirp, unsigned count);",
        /* __NR_set_tid_address 218 */
       "long set_tid_address(int *tidptr);",
        /* __NR_restart_syscall 219 */
  @@ -706,9 +706,9 @@
        /* __NR_mq_unlink 241 */
       "int mq_unlink(const char *name);",
        /* __NR_mq_timedsend 242 */
  -    "int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, 
unsigned int msg_prio, const struct timespec *abs_timeout);",
  +    "int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, 
unsigned msg_prio, const struct timespec *abs_timeout);",
        /* __NR_mq_timedreceive 243 */
  -    "ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, 
unsigned int *msg_prio, const struct timespec *abs_timeout);",
  +    "ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, 
unsigned *msg_prio, const struct timespec *abs_timeout);",
        /* __NR_mq_notify 244 */
       "int mq_notify(mqd_t mqdes, const struct sigevent *sevp);",
        /* __NR_mq_getsetattr 245 */
  @@ -770,13 +770,13 @@
        /* __NR_get_robust_list 274 */
       "long get_robust_list(int pid, struct robust_list_head **head_ptr, 
size_t *len_ptr);",
        /* __NR_splice 275 */
  -    "ssize_t splice(int in_fdno, loff_t *in_off, int out_fdno, loff_t 
*out_off, size_t len, unsigned int flags);",
  +    "ssize_t splice(int in_fdno, loff_t *in_off, int out_fdno, loff_t 
*out_off, size_t len, unsigned flags);",
        /* __NR_tee 276 */
  -    "ssize_t tee(int in_fdno, int out_fdno, size_t len, unsigned int 
flags);",
  +    "ssize_t tee(int in_fdno, int out_fdno, size_t len, unsigned flags);",
        /* __NR_sync_file_range 277 */
  -    "int sync_file_range(int fdno, off64_t offset, off64_t nbytes, unsigned 
int flags);",
  +    "int sync_file_range(int fdno, off64_t offset, off64_t nbytes, unsigned 
flags);",
        /* __NR_vmsplice 278 */
  -    "ssize_t vmsplice(int fdno, const struct iovec *iov, unsigned long 
nr_segs, unsigned int flags);",
  +    "ssize_t vmsplice(int fdno, const struct iovec *iov, unsigned long 
nr_segs, unsigned flags);",
        /* __NR_move_pages 279 */
       "long move_pages(int pid, unsigned long count, void **pages, const int 
*nodes, int *status, int flags);",
        /* __NR_utimensat 280 */
  @@ -788,7 +788,7 @@
        /* __NR_timerfd_create 283 */
       "int timerfd_create(int clockid, int flags);",
        /* __NR_eventfd 284 */
  -    "int eventfd(unsigned int initval, int flags);",
  +    "int eventfd(unsigned initval, int flags);",
        /* __NR_fallocate 285 */
       "int fallocate(int fdno, int mode, off_t offset, off_t len);",
        /* __NR_timerfd_settime 286 */
  @@ -799,7 +799,7 @@
       "int accept4(int sockfdno, struct sockaddr *addr, socklen_t *addrlen, 
int flags);",
        /* __NR_signalfd4 289 */
        /* __NR_eventfd2 290 */
  -    "int eventfd(unsigned int initval, int flags);",
  +    "int eventfd(unsigned initval, int flags);",
        /* __NR_epoll_create1 291 */
       "int epoll_create1(int flags);",
        /* __NR_dup3 292 */
  @@ -816,11 +816,11 @@
        /* __NR_perf_event_open 298 */
       "int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, 
int group_fdno, unsigned long flags);",
        /* __NR_recvmmsg 299 */
  -    "int recvmmsg(int sockfdno, struct mmsghdr *msgvec, unsigned int vlen, 
unsigned int flags, struct timespec *timeout);",
  +    "int recvmmsg(int sockfdno, struct mmsghdr *msgvec, unsigned vlen, 
unsigned flags, struct timespec *timeout);",
        /* __NR_fanotify_init 300 */
  -    "int fanotify_init(unsigned int flags, unsigned int event_f_flags);",
  +    "int fanotify_init(unsigned flags, unsigned event_f_flags);",
        /* __NR_fanotify_mark 301 */
  -    "int fanotify_mark(int fanotify_fdno, unsigned int flags, uint64_t mask, 
int dirfdno, const char *pathname);",
  +    "int fanotify_mark(int fanotify_fdno, unsigned flags, uint64_t mask, int 
dirfdno, const char *pathname);",
        /* __NR_prlimit64 302 */
       "int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, 
struct rlimit *old_limit);",
        /* __NR_name_to_handle_at 303 */
  @@ -831,7 +831,7 @@
        /* __NR_syncfs 306 */
       "int syncfs(int fdno);",
        /* __NR_sendmmsg 307 */
  -    "int sendmmsg(int sockfdno, struct mmsghdr *msgvec, unsigned int vlen, 
unsigned int flags);",
  +    "int sendmmsg(int sockfdno, struct mmsghdr *msgvec, unsigned vlen, 
unsigned flags);",
        /* __NR_setns 308 */
       "int setns(int fdno, int nstype);",
        /* __NR_getcpu 309 */
  @@ -845,21 +845,21 @@
        /* __NR_finit_module 313 */
       "int finit_module(int fdno, const char *param_values, int flags);",
        /* __NR_sched_setattr 314 */
  -    "int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int 
flags);",
  +    "int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned flags);",
        /* __NR_sched_getattr 315 */
  -    "int sched_getattr(pid_t pid, struct sched_attr *attr, unsigned int 
size, unsigned int flags);",
  +    "int sched_getattr(pid_t pid, struct sched_attr *attr, unsigned size, 
unsigned flags);",
        /* __NR_renameat2 316 */
  -    "int renameat2(int olddirfdno, const char *oldpath, int newdirfdno, 
const char *newpath, unsigned int flags);",
  +    "int renameat2(int olddirfdno, const char *oldpath, int newdirfdno, 
const char *newpath, unsigned flags);",
        /* __NR_seccomp 317 */
  -    "int seccomp(unsigned int operation, unsigned int flags, void *args);",
  +    "int seccomp(unsigned operation, unsigned flags, void *args);",
        /* __NR_getrandom 318 */
  -    "int getrandom(void *buf, size_t buflen, unsigned int flags);",
  +    "int getrandom(void *buf, size_t buflen, unsigned flags);",
        /* __NR_memfd_create 319 */
  -    "int memfd_create(const char *name, unsigned int flags);",
  +    "int memfd_create(const char *name, unsigned flags);",
        /* __NR_kexec_file_load 320 */
       "long kexec_file_load(int kernel_fdno, int initrd_fdno, unsigned long 
cmdline_len, const char *cmdline, unsigned long flags);",
        /* __NR_bpf 321 */
  -    "int bpf(int cmd, union bpf_attr *attr, unsigned int size);",
  +    "int bpf(int cmd, union bpf_attr *attr, unsigned size);",
        /* __NR_execveat 322 */
       "int execveat(int dirfdno, const char *pathname, char *const argv[], 
char *const envp[], int flags);",
        /* __NR_userfaultfd 323 */
  @@ -869,7 +869,7 @@
        /* __NR_mlock2 325 */
       "int mlock2(const void *addr, size_t len, int flags);",
        /* __NR_copy_file_range 326 */
  -    "ssize_t copy_file_range(int in_fdno, loff_t *in_off, int out_fdno, 
loff_t *out_off, size_t len, unsigned int flags);",
  +    "ssize_t copy_file_range(int in_fdno, loff_t *in_off, int out_fdno, 
loff_t *out_off, size_t len, unsigned flags);",
        /* __NR_preadv2 327 */
       "ssize_t preadv2(int fdno, const struct iovec *iov, int iovcnt, off_t 
offset, int flags);",
        /* __NR_pwritev2 328 */
  @@ -962,6 +962,7 @@
       unsigned nlongs;
       unsigned nlonglongs;
       unsigned nother;
  +    rpmmc mc;
       char b[BUFSIZ];
   };
   struct rpmwrap_s _wrap;
  @@ -976,6 +977,7 @@
        wrap->items = argvFree(wrap->items);
        wrap->argtypes = argvFree(wrap->argtypes);
        wrap->argnames = argvFree(wrap->argnames);
  +     wrap->mc = rpmmcFree(wrap->mc);
        memset(wrap, 0, sizeof(*wrap));
       }
   }
  @@ -1036,7 +1038,6 @@
        } else
        if (!strcmp(argtype, "int")
         || !strcmp(argtype, "unsigned")
  -      || !strcmp(argtype, "unsigned int")
         || !strcmp(argtype, "uint32_t")
         || !strcmp(argtype, "uid_t")
         || !strcmp(argtype, "gid_t")
  @@ -1084,9 +1085,7 @@
            te += sprintf(te, "\treq->nav%u = va_arg(ap, %s);\n", 
wrap->ndoubles, argtype);
        } else
        if (!strcmp(argtype, "long")
  -      || !strcmp(argtype, "long int")
         || !strcmp(argtype, "unsigned long")
  -      || !strcmp(argtype, "unsigned long int")
         || !strcmp(argtype, "nfds_t")
         || !strcmp(argtype, "aio_context_t")
        ) {
  @@ -1136,7 +1135,6 @@
        return "%d";
   
       if (!strcmp(argtype, "unsigned")
  -     || !strcmp(argtype, "unsigned int")
        || !strcmp(argtype, "uint32_t")
        || !strcmp(argtype, "uid_t")
        || !strcmp(argtype, "gid_t")
  @@ -1171,12 +1169,10 @@
        || !strcmp(argtype, "struct timespec"))
        return "%f";
   
  -    if (!strcmp(argtype, "long")
  -     || !strcmp(argtype, "long int"))
  +    if (!strcmp(argtype, "long"))
        return "%ld";
   
  -    if (!strcmp(argtype, "unsigned long")
  -     || !strcmp(argtype, "unsigned long int"))
  +    if (!strcmp(argtype, "unsigned long"))
        return "%lu";
   
       if (!strcmp(argtype, "nfds_t"))
  @@ -1186,7 +1182,6 @@
        return "0x%lx";
   
       if (!strcmp(argtype, "long long")
  -     || !strcmp(argtype, "long long int")
        || !strcmp(argtype, "int64_t"))
        return "%lld";
   
  @@ -1194,7 +1189,6 @@
        return "0x%llx";
   
       if (!strcmp(argtype, "unsigned long long")
  -     || !strcmp(argtype, "unsigned long long int")
        || !strcmp(argtype, "uint64_t")
        || !strcmp(argtype, "u64"))
        return "%llu";
  @@ -1277,6 +1271,105 @@
   
   }
   
  +static void wrapExpand(rpmwrap wrap, FILE * fp)
  +{
  +    char *te = wrap->b;
  +(void)te;
  +    int nargs = argvCount(wrap->argtypes);
  +(void)nargs;
  +
  +    char *msg;
  +    if (fp == NULL)  fp = stderr;
  +
  +    msg = rpmMCExpand(wrap->mc,
  +             "items: %{@items:, }\n",
  +             "argtypes: %{@argtypes:, }\n",
  +             "argnames: %{@argnames:, }\n",
  +             NULL);
  +fprintf(fp, "%s", msg);
  +    msg = _free(msg);
  +
  +    char * str =
  +#ifdef       DYING
  +     "int,"
  +     "unsigned,"
  +     "long,"
  +     "unsigned long,"
  +     "long long,"
  +     "unsigned long long,"
  +#endif
  +     "%{@argtypes:,}";
  +    char *xstr = rpmMCExpand(wrap->mc, str, NULL);
  +    msg = rpmMCExpand(wrap->mc,
  +             "XXX\t|", str, "| ==> ",
  +             "|%{sed",
  +    " -e s/[^,]*\\\\*[^,]*/%p/g",
  +    " -e s/[^,]*\\\\][^,]*/%p/g",
  +    " -e s/[^,]*enum\\\\s[^,]*,/0x%x/g",
  +    " -e s/[^,]*void//g",
  +    " -e 
s/[^,]*(caddr_t|timer_t|cap_user_data_t|cap_user_header_t|eio_wd|eio_req)/%p/g"
  +    " -e s/[^,]*off64_t/0x%llx/g", 
  +    " -e s/[^,]*nfds_t/%lu/g",
  +    " -e s/[^,]*off_t/0x%lx/g",
  +    " -e s/[^,]*aio_context_t/0x%lx/g",
  +    " -e s/[^,]*(mqd_t|key_serial_t|key_t|dev_t|socklen_t|clockid_t)/0x%x/g",
  +    " -e s/[^,]*(uid_t|gid_t|pid_t|id_t)/%u/g",
  +    " -e s/[^,]*mode_t/0%o/g",
  +    " -e s/[^,]*ssize_t/%zd/g",
  +    " -e s/[^,]*size_t/%zu/g",
  +    " -e s/[^,]*double/%f/g",
  +    " -e s/[^,]*struct\\\\s(timeval|timespec)/%f/g",
  +
  +    " -e s/[^,]*(u64|uint64_t|unsigned\\\\slong\\\\slong)/%lu/g",
  +    " -e s/[^,]*(i64|int64_t|long\\\\slong)/%ld/g",
  +    " -e s/[^,]*(unsigned\\\\slong)/%lu/g",
  +    " -e s/[^,]*(long)/%ld/g",
  +    " -e s/[^,]*(u32|u16|u8|uint32_t|uint16_t|uint8_t|unsigned)/%u/g",
  +    " -e s/[^,]*(i32|i16|i8|int32_t|int16_t|int8_t|int)/%d/g",
  +             ":", xstr, "}|\n",
  +             NULL);
  +    xstr = _free(xstr);
  +fprintf(fp, "%s", msg);
  +    msg = _free(msg);
  +
  +#ifdef       NOTYET
  +    for (int i = 0; i < nargs; i++) {
  +     const char * argtype = wrap->argtypes[i];
  +     const char * argname = wrap->argnames[i];
  +(void)argname;
  +
  +     msg = rpmMCExpand(wrap->mc, "\t|", argtype, "| ==> ",
  +             "|%{sed",
  +    " -e s/.*\\\\*/%p/",
  +    " -e s/.*\\\\]/%p/",
  +    " -e s/.*enum.*/0x%x/",
  +    " -e s/^void$//",
  +    " -e 
s/^(caddr_t|timer_t|cap_user_data_t|cap_user_header_t|eio_wd|eio_req)$/%p/"
  +    " -e s/^(unsigned.long.long.int|unsigned.long.long|uint64_t|u64)$/%llu/",
  +    " -e s/^(long.long|long.long.int|int64_t)$/%lld/",
  +    " -e s/^off64_t$/0x%llx/", 
  +    " -e s/^(long|long.int)$/%ld/",
  +    " -e s/^(unsigned.long|unsigned.long.int)$/%lu/",
  +    " -e s/^nfds_t$/%lu/",
  +    " -e s/^off_t$/0x%lx/",
  +    " -e s/^aio_context_t$/0x%lx/",
  +    " -e s/^(int|int32_t)$/%d/",
  +    " -e s/^(unsigned|uint32_t|uid_t|gid_t|pid_t|id_t)$/%u/",
  +    " -e s/^(mqd_t|key_serial_t|key_t|dev_t|socklen_t|clockid_t)$/0x%x/",
  +    " -e s/^mode_t$/0%o/",
  +    " -e s/^ssize_t$/%zd/",
  +    " -e s/^size_t$/%zu/",
  +    " -e s/^double$/%f/",
  +    " -e s/^struct.(timeval|timespec)$/%f/",
  +             " :", argtype, "}|",
  +             NULL);
  +fprintf(fp, "%s\n", msg);
  +     msg = _free(msg);
  +
  +    }
  +#endif       /* NOTYET */
  +}
  +
   static int spewEIO(ARGV_t av, int ac)
   {
   rpmwrap wrap = &_wrap;
  @@ -1287,14 +1380,17 @@
        char *te;
        int xx;
   
  +wrap->mc = rpmmcNew(NULL, 0);
        char * proto = xstrdup(protos[i]);
   wrap->proto = xstrdup(proto);
  +addMacro(wrap->mc, "proto", NULL, wrap->proto, 0);
        t = strchr(proto, '(');
        *t++ = '\0';
        char *arglist = t;
        t = strrchr(arglist, ')');
        *t++ = '\0';
   wrap->arglist = xstrdup(arglist);
  +addMacro(wrap->mc, "arglist", NULL, wrap->arglist, 0);
   
        char * subtype = proto;
   
  @@ -1311,7 +1407,9 @@
             t = proto;
        char * subname = t;
   wrap->subname = xstrdup(subname);
  +addMacro(wrap->mc, "subname", NULL, wrap->subname, 0);
   wrap->subtype = xstrdup(subtype);
  +addMacro(wrap->mc, "subtype", NULL, wrap->subtype, 0);
   
        ARGV_t items = NULL;
        xx = argvSplit(&items, arglist, ",");
  @@ -1327,6 +1425,7 @@
            items[i] = _free(items[i]);
            items[i] = item;
   xx = argvAdd(&wrap->items, item);
  +addMacro(wrap->mc, "items", NULL, item, 0);
            char * argtype = item;
   
            /* XXX need to handle '**' */
  @@ -1343,7 +1442,9 @@
                t = "";
            char * argname = t;
   xx = argvAdd(&wrap->argtypes, argtype);
  +addMacro(wrap->mc, "argtypes", NULL, argtype, 0);
   xx = argvAdd(&wrap->argnames, argname);
  +addMacro(wrap->mc, "argnames", NULL, argname, 0);
        }
   
        items = argvFree(items);
  @@ -1351,7 +1452,11 @@
   
   wrapAnalyze(wrap, NULL);
   wrapDump(__FUNCTION__, wrap, NULL);
  +
   wrapPrint(wrap, NULL);
  +wrapExpand(wrap, NULL);
  +
  +rpmDumpMacroTable(wrap->mc, NULL);
   wrapFree(wrap);
   
       }
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to