github.com/gotranspile/cxgo@v0.3.7/libs/sys_types.go (about)

     1  package libs
     2  
     3  import (
     4  	"github.com/gotranspile/cxgo/runtime/csys"
     5  	"github.com/gotranspile/cxgo/types"
     6  )
     7  
     8  const (
     9  	sysTypesH = "sys/types.h"
    10  )
    11  
    12  func init() {
    13  	RegisterLibrary(sysTypesH, func(c *Env) *Library {
    14  		intT := types.IntT(4)
    15  		return &Library{
    16  			Idents: map[string]*types.Ident{
    17  				"O_RDONLY": c.NewIdent("O_RDONLY", "csys.O_RDONLY", csys.O_RDONLY, intT),
    18  				"O_WRONLY": c.NewIdent("O_WRONLY", "csys.O_WRONLY", csys.O_WRONLY, intT),
    19  				"O_RDWR":   c.NewIdent("O_RDWR", "csys.O_RDWR", csys.O_RDWR, intT),
    20  				"O_CREAT":  c.NewIdent("O_CREAT", "csys.O_CREAT", csys.O_CREAT, intT),
    21  				"O_EXCL":   c.NewIdent("O_EXCL", "csys.O_EXCL", csys.O_EXCL, intT),
    22  				"O_TRUNC":  c.NewIdent("O_TRUNC", "csys.O_TRUNC", csys.O_TRUNC, intT),
    23  			},
    24  			// TODO
    25  			Header: `
    26  #include <` + BuiltinH + `>
    27  #include <` + stddefH + `>
    28  #include <` + timeH + `>
    29  
    30  #define off_t _cxgo_int64
    31  #define ssize_t _cxgo_int64
    32  #define off_t _cxgo_uint64
    33  #define pid_t _cxgo_uint64
    34  #define gid_t _cxgo_uint32
    35  #define uid_t _cxgo_uint32
    36  #define ino_t _cxgo_uint64
    37  
    38  #define u_short unsigned short
    39  #define u_long unsigned long
    40  
    41  
    42  // TODO: should be in fcntl.h
    43  const _cxgo_int32 O_RDONLY = 1;
    44  const _cxgo_int32 O_WRONLY = 2;
    45  const _cxgo_int32 O_RDWR = 3;
    46  const _cxgo_int32 O_CREAT = 4;
    47  const _cxgo_int32 O_EXCL = 5;
    48  const _cxgo_int32 O_TRUNC = 6;
    49  `,
    50  		}
    51  	})
    52  }