On Mon, Aug 22, 2011 at 05:03:58PM +0200, Alexander Burger wrote:
> Moreover, they can be easily cross-generated. If we have proper a
> "src64/sys/x86-64.openBsd.code.l" and "src64/sys/x86-64.openBsd.defs.l"

To generate the "src64/sys/*.defs.l" files, I always used the attached
"def.c". If you like, you could compile it on OpenBSD, and send me the
output. I could make "src64/sys/x86-64.openBsd.defs.l" then.

For the "src64/sys/*.code.l" files, things are a bit more tricky. I
usually worte short test programs in C, and then inspected them with
'objdump -S'. I don't know how this works out in OpenBSD.

Cheers,
- Alex
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h> 
#include <signal.h>
#include <dlfcn.h>
#include <termio.h>
#include <time.h>
#include <poll.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/resource.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/tcp.h>

#include <regex.h>

int main() {
   struct sigaction act;
   struct termios term;
   struct flock fl;
   struct stat st;
   struct tms tim;
   fd_set rdSet;
   struct dirent dir;
   struct hostent host;
   struct in_addr iaddr;
   struct sockaddr_in addr;
   regex_t regex;

   printf("int %d\n", sizeof(int));
   printf("long %d\n", sizeof(long));
   printf("off_t %d\n", sizeof(off_t));
   printf("pid_t %d\n", sizeof(pid_t));
   printf("ssize_t %d\n", sizeof(ssize_t));
   printf("errno %d\n", sizeof(errno));
   printf("MAXPATHLEN %d\n", PATH_MAX);
   printf("BUFSIZ %d\n", BUFSIZ);
   printf("PIPE_BUF %d\n", PIPE_BUF);
   printf("F_GETFD %d\n", F_GETFD);
   printf("F_SETFD %d\n", F_SETFD);
   printf("FD_CLOEXEC %d\n", FD_CLOEXEC);
   printf("ECONNRESET %d\n", ECONNRESET);
   printf("\n");
   printf("RTLD_LAZY %d\n", RTLD_LAZY);
   printf("RTLD_GLOBAL %d\n", RTLD_GLOBAL);
   printf("\n");
   printf("time_t %d\n", sizeof(time_t));
   printf("suseconds_t %d\n", sizeof(suseconds_t));
   printf("\n");
   printf("sigaction %d\n", sizeof(act));
   printf("sigset_t %d\n", sizeof(sigset_t));
   printf("sa_handler %d\n", (char*)&act.sa_handler - (char*)&act);
   printf("sa_sigaction %d\n", (char*)&act.sa_sigaction - (char*)&act);
   printf("sa_mask %d\n", (char*)&act.sa_mask - (char*)&act);
   printf("sa_flags %d\n", (char*)&act.sa_flags - (char*)&act);
   printf("SIG_DFL %d\n", SIG_DFL);
   printf("SIG_IGN %d\n", SIG_IGN);
   printf("SIG_UNBLOCK %d\n", SIG_UNBLOCK);
   printf("\n");
   printf("WNOHANG %d\n", WNOHANG);
   printf("WUNTRACED %d\n", WUNTRACED);
   printf("\n");
   printf("termios %d\n", sizeof(term));
   printf("tcflag_t %d\n", sizeof(tcflag_t));
   printf("c_iflag %d\n", (char*)&term.c_iflag - (char*)&term);
   printf("c_lflag %d\n", (char*)&term.c_lflag - (char*)&term);
   printf("c_cc %d\n", (char*)&term.c_cc - (char*)&term);
   printf("ISIG %d\n", ISIG);
   printf("VMIN %d\n", VMIN);
   printf("VTIME %d\n", VTIME);
   printf("TCSADRAIN %d\n", TCSADRAIN);
   printf("\n");
   printf("flock %d\n", sizeof(fl));
   printf("fl.l_type %d\n", (char*)&fl.l_type - (char*)&fl);
   printf("fl.l_whence %d\n", (char*)&fl.l_whence - (char*)&fl);
   printf("fl.l_start %d\n", (char*)&fl.l_start - (char*)&fl);
   printf("fl.l_len %d\n", (char*)&fl.l_len - (char*)&fl);
   printf("fl.l_pid %d\n", (char*)&fl.l_pid - (char*)&fl);
   printf("SEEK_SET %d\n", SEEK_SET);
   printf("SEEK_CUR %d\n", SEEK_CUR);
   printf("F_RDLCK %d\n", F_RDLCK);
   printf("F_WRLCK %d\n", F_WRLCK);
   printf("F_UNLCK %d\n", F_UNLCK);
   printf("F_GETFL %d\n", F_GETFL);
   printf("F_SETFL %d\n", F_SETFL);
   printf("F_GETLK %d\n", F_GETLK);
   printf("F_SETLK %d\n", F_SETLK);
   printf("F_SETLKW %d\n", F_SETLKW);
   printf("F_SETOWN %d\n", F_SETOWN);
   printf("O_NONBLOCK %d\n", O_NONBLOCK);
   printf("O_ASYNC %d\n", O_ASYNC);
   printf("\n");
   printf("stat %d\n", sizeof(st));
   printf("st.st_mode %d\n", (char*)&st.st_mode - (char*)&st);
   printf("mode_t %d\n", sizeof(mode_t));
   printf("st.st_size %d\n", (char*)&st.st_size - (char*)&st);
   printf("st.st_mtime %d\n", (char*)&st.st_mtime - (char*)&st);
   printf("S_IFMT %X\n", S_IFMT);
   printf("S_IFDIR %X\n", S_IFDIR);
   printf("\n");
   printf("tms %d\n", sizeof(tim));
   printf("fd_set %d\n", sizeof(rdSet));
   printf("clock_t %d\n", sizeof(clock_t));
   printf("tim.tms_utime %d\n", (char*)&tim.tms_utime - (char*)&tim);
   printf("tim.tms_stime %d\n", (char*)&tim.tms_stime - (char*)&tim);
   printf("\n");
   printf("rlim_t %d\n", sizeof(rlim_t));
   printf("RLIM_INFINITY %d\n", RLIM_INFINITY);
   printf("RLIMIT_STACK %d\n", RLIMIT_STACK);
   printf("\n");
   printf("dir.d_name %d\n", (char*)&dir.d_name - (char*)&dir);
   printf("\n");
   printf("IPPROTO_TCP %d\n", IPPROTO_TCP);
   printf("TCP_NODELAY %d\n", TCP_NODELAY);
   printf("\n");
   printf("hostent %d\n", sizeof(host));
   printf("host.h_name %d\n", (char*)&host.h_name - (char*)&host);
   printf("host.h_length %d\n", (char*)&host.h_length - (char*)&host);
   printf("host.h_addr_list %d\n", (char*)&host.h_addr_list - (char*)&host);
   printf("\n");
   printf("in_addr %d\n", sizeof(iaddr));
   printf("iaddr.s_addr %d\n", (char*)&iaddr.s_addr - (char*)&iaddr);
   printf("\n");
   printf("sockaddr_in %d\n", sizeof(addr));
   printf("addr.sin_addr %d\n", (char*)&addr.sin_addr - (char*)&addr);
   printf("addr.sin_addr.s_addr %d\n", (char*)&addr.sin_addr.s_addr - (char*)&addr);
   printf("addr.sin_port %d\n", (char*)&addr.sin_port - (char*)&addr);
   printf("addr.sin_family %d\n", (char*)&addr.sin_family - (char*)&addr);
   printf("AF_INET %d\n", AF_INET);
   printf("SOCK_STREAM %d\n", SOCK_STREAM);
   printf("SOCK_DGRAM %d\n", SOCK_DGRAM);
   printf("INADDR_ANY %d\n", INADDR_ANY);
   printf("SOL_SOCKET %d\n", SOL_SOCKET);
   printf("SO_REUSEADDR %d\n", SO_REUSEADDR);
   printf("\n");
   printf("REG_EXTENDED %d\n", REG_EXTENDED);
   printf("sockaddr_in %d\n", sizeof(regex));
   return 0;
}

Reply via email to