Hi Amit,

> Okay, here's the output on amd64 attached to email.

Thanks for the input!


Now I created a first x86-64.openBsd.defs.l (see attachment).

I set most values as they are in your output. However, there are also
some values not covered by def.c, because I took them directly from the
include files. These concern the ranges

   ENOENT   .. ECONNRESET
   O_RDONLY .. O_APPEND
   SIGHUP   .. SIGNALS
   TM_SEC   .. TM_YEAR

Could you check if they are correct?


> > 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.
> 
> Will you please send the test programs?

Unfortunately, I don't have a definite test progam. It was more an
interactive search, writing code snippets, or disassembling other
programs with 'gdb'.

So I now wrote a short "code.c" program (also attached). Can you compile
this with

   $ gcc -S code.c

and send me the resulting "code.s"? I'll see if it helps me to extract
what is needed.


> Do you need ppc64
> too after amd64 works? I can ask somebody on porting list to give me
> the output for ppc64. They are a friendly bunch when in the right
> mood.

That's good to hear. For now, I would say, we better try to get x86-64
running first, and then tackle ppc64.

Cheers,
- Alex
# 25aug11abu
# Amit Kulkarni <amitk...@gmail.com>
# (c) Software Lab. Alexander Burger

# errno
(equ ENOENT 2)       # No such file or directory
(equ EINTR 4)        # Interrupted system call
(equ EBADF 9)        # Bad file number
(equ EAGAIN 11)      # Try again
(equ EACCES 13)      # Permission denied
(equ EPIPE 32)       # Broken pipe
(equ ECONNRESET 54)  # Connection reset by peer

# open/fcntl
(equ O_RDONLY 0)
(equ O_WRONLY 1)
(equ O_RDWR 2)
(equ O_CREAT 64)
(equ O_EXCL 128)
(equ O_TRUNC 512)
(equ O_APPEND 1024)
(equ F_GETFD 1)
(equ F_SETFD 2)
(equ FD_CLOEXEC 1)

# stdio
(equ BUFSIZ 1024)
(equ PIPE_BUF 512)

(equ MAXPATHLEN 1024)

# dlfcn
(equ RTLD_LAZY 1)
(equ RTLD_GLOBAL 256)

# fcntl
(equ FLOCK 32)    # File lock structure
(equ L_TYPE 0)  # 2
(equ L_WHENCE 2)  # 2
(equ L_START 8)
(equ L_LEN 16)
(equ L_PID 24)
(equ SEEK_SET 0)
(equ SEEK_CUR 1)
(equ F_RDLCK 0)
(equ F_WRLCK 1)
(equ F_UNLCK 2)
(equ F_GETFL 3)
(equ F_SETFL 4)
(equ F_GETLK 5)
(equ F_SETLK 6)
(equ F_SETLKW 7)
(equ F_SETOWN 8)
(equ O_NONBLOCK 2048)
(equ O_ASYNC 8192)

# stat
(equ STAT 144)    # File status structure
(equ ST_MODE 24)  # 4
(equ ST_SIZE 48)
(equ ST_MTIME 88)
(equ S_IFMT (hex "F000"))
(equ S_IFDIR (hex "4000"))

# times
(equ TMS 32)  # 'times' structure
(equ TMS_UTIME 0)
(equ TMS_STIME 8)

# termios
(equ TERMIOS (+ 60 4))  # Terminal I/O structure (+ Padding)
(equ C_IFLAG 0)
(equ C_LFLAG 12)
(equ C_CC 17)
(equ ISIG 128)
(equ VMIN 5)
(equ VTIME 7)
(equ TCSADRAIN 1)

# signal
(equ SIGACTION 16)  # Sigaction structure
(equ SIGSET_T 8)    # 4 -> aligned to word size
(equ SA_HANDLER 0)
(equ SA_MASK 8)
(equ SA_FLAGS 12)

(equ SIG_DFL 0)
(equ SIG_IGN 1)
(equ SIG_UNBLOCK 2)

(equ SIGHUP 1)  # Signals
(equ SIGINT 2)
(equ SIGUSR1 10)
(equ SIGUSR2 12)
(equ SIGPIPE 13)
(equ SIGALRM 14)
(equ SIGTERM 15)
(equ SIGCHLD 17)
(equ SIGCONT 18)
(equ SIGSTOP 19)
(equ SIGTSTP 20)
(equ SIGTTIN 21)
(equ SIGTTOU 22)
(equ SIGIO 29)
(equ SIGNALS 30)  # Highest used signal number plus 1

# wait
(equ WNOHANG 1)
(equ WUNTRACED 2)

# select
(equ FD_SET 128)  # 1024 bit

# time
(equ TM_SEC 0)
(equ TM_MIN 4)
(equ TM_HOUR 8)
(equ TM_MDAY 12)
(equ TM_MON 16)
(equ TM_YEAR 20)

# dir
(equ D_NAME 8)

# Sockets
(equ HOSTENT 32)
(equ H_NAME 0)
(equ H_LENGTH 20)
(equ H_ADDR_LIST 24)

(equ IN_ADDR 4)
(equ S_ADDR 0)

(equ SOCKADDR_IN 32)
(equ SIN_ADDR 4)
(equ SIN_ADDR.S_ADDR 4)
(equ SIN_PORT 2)
(equ SIN_FAMILY 1)
(equ AF_INET 2)
(equ SOCK_STREAM 1)
(equ SOCK_DGRAM 2)
(equ INADDR_ANY 0)
(equ SOL_SOCKET 65535)
(equ SO_REUSEADDR 4)

# vi:et:ts=3:sw=3
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int main(void) {
   int n;
   struct stat st;

   int a = errno;
   int b = S_ISDIR(st.st_mode);
   int c = WIFSTOPPED(n);
   int d = WIFSIGNALED(n);
   int e = WTERMSIG(n);
   /* Next line is to stop optimizer to throw away the above code */
   printf("%d %d %d %d %d\n", a, b, c, d, e);
}

Reply via email to