unix: add a step to mkall.go that generates ABI headers to be referenced from types.go

Change-Id: I3ecf7802c152b82c0d40f8b1bebcb25feda7fb13
Reviewed-on: https://go-review.googlesource.com/106315
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
diff --git a/unix/linux/mkall.go b/unix/linux/mkall.go
index 89b2fe8..40b5cf4 100644
--- a/unix/linux/mkall.go
+++ b/unix/linux/mkall.go
@@ -17,6 +17,9 @@
 import (
 	"bufio"
 	"bytes"
+	"debug/elf"
+	"encoding/binary"
+	"errors"
 	"fmt"
 	"io"
 	"io/ioutil"
@@ -292,7 +295,7 @@
 	return nil
 }
 
-// Create the Linux and glibc headers in the include directory.
+// Create the Linux, glibc and ABI (C compiler convention) headers in the include directory.
 func (t *target) makeHeaders() error {
 	// Make the Linux headers we need for this architecture
 	linuxMake := makeCommand("make", "headers_install", "ARCH="+t.LinuxArch, "INSTALL_HDR_PATH="+TempDir)
@@ -327,6 +330,114 @@
 		file.Close()
 	}
 
+	// ABI headers will specify C compiler behavior for the target platform.
+	return t.makeABIHeaders()
+}
+
+// makeABIHeaders generates C header files based on the platform's calling convention.
+// While many platforms have formal Application Binary Interfaces, in practice, whatever the
+// dominant C compilers generate is the de-facto calling convention.
+//
+// We generate C headers instead of a Go file, so as to enable references to the ABI from Cgo.
+func (t *target) makeABIHeaders() (err error) {
+	abiDir := filepath.Join(IncludeDir, "abi")
+	if err = os.Mkdir(abiDir, os.ModePerm); err != nil {
+		return err
+	}
+
+	cc := os.Getenv("CC")
+	if cc == "" {
+		return errors.New("CC (compiler) env var not set")
+	}
+
+	// Build a sacrificial ELF file, to mine for C compiler behavior.
+	binPath := filepath.Join(TempDir, "tmp_abi.o")
+	bin, err := t.buildELF(cc, cCode, binPath)
+	if err != nil {
+		return fmt.Errorf("cannot build ELF to analyze: %v", err)
+	}
+	defer bin.Close()
+	defer os.Remove(binPath)
+
+	// Right now, we put everything in abi.h, but we may change this later.
+	abiFile, err := os.Create(filepath.Join(abiDir, "abi.h"))
+	if err != nil {
+		return err
+	}
+	defer func() {
+		if cerr := abiFile.Close(); cerr != nil && err == nil {
+			err = cerr
+		}
+	}()
+
+	if err = t.writeBitFieldMasks(bin, abiFile); err != nil {
+		return fmt.Errorf("cannot write bitfield masks: %v", err)
+	}
+
+	return nil
+}
+
+func (t *target) buildELF(cc, src, path string) (*elf.File, error) {
+	// Compile the cCode source using the set compiler - we will need its .data section.
+	// Do not link the binary, so that we can find .data section offsets from the symbol values.
+	ccCmd := makeCommand(cc, "-o", path, "-gdwarf", "-x", "c", "-c", "-")
+	ccCmd.Stdin = strings.NewReader(src)
+	ccCmd.Stdout = os.Stdout
+	if err := ccCmd.Run(); err != nil {
+		return nil, fmt.Errorf("compiler error: %v", err)
+	}
+
+	bin, err := elf.Open(path)
+	if err != nil {
+		return nil, fmt.Errorf("cannot read ELF file %s: %v", path, err)
+	}
+
+	return bin, nil
+}
+
+func (t *target) writeBitFieldMasks(bin *elf.File, out io.Writer) error {
+	symbols, err := bin.Symbols()
+	if err != nil {
+		return fmt.Errorf("getting ELF symbols: %v", err)
+	}
+	var masksSym *elf.Symbol
+
+	for _, sym := range symbols {
+		if sym.Name == "masks" {
+			masksSym = &sym
+		}
+	}
+
+	if masksSym == nil {
+		return errors.New("could not find the 'masks' symbol in ELF symtab")
+	}
+
+	dataSection := bin.Section(".data")
+	if dataSection == nil {
+		return errors.New("ELF file has no .data section")
+	}
+
+	data, err := dataSection.Data()
+	if err != nil {
+		return fmt.Errorf("could not read .data section: %v\n", err)
+	}
+
+	var bo binary.ByteOrder
+	if t.BigEndian {
+		bo = binary.BigEndian
+	} else {
+		bo = binary.LittleEndian
+	}
+
+	// 64 bit masks of type uint64 are stored in the data section starting at masks.Value.
+	// Here we are running on AMD64, but these values may be big endian or little endian,
+	// depending on target architecture.
+	for i := uint64(0); i < 64; i++ {
+		off := masksSym.Value + i*8
+		// Define each mask in native by order, so as to match target endian.
+		fmt.Fprintf(out, "#define BITFIELD_MASK_%d %dULL\n", i, bo.Uint64(data[off:off+8]))
+	}
+
 	return nil
 }
 
@@ -480,3 +591,160 @@
 	fmt.Fprintf(w, "\treturn ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))\n")
 	fmt.Fprintf(w, "}\n")
 }
+
+// cCode is compiled for the target architecture, and the resulting data section is carved for
+// the statically initialized bit masks.
+const cCode = `
+// Bit fields are used in some system calls and other ABIs, but their memory layout is
+// implementation-defined [1]. Even with formal ABIs, bit fields are a source of subtle bugs [2].
+// Here we generate the offsets for all 64 bits in an uint64.
+// 1: http://en.cppreference.com/w/c/language/bit_field
+// 2: https://lwn.net/Articles/478657/
+
+#include <stdint.h>
+
+struct bitfield {
+	union {
+		uint64_t val;
+		struct {
+			uint64_t u64_bit_0 : 1;
+			uint64_t u64_bit_1 : 1;
+			uint64_t u64_bit_2 : 1;
+			uint64_t u64_bit_3 : 1;
+			uint64_t u64_bit_4 : 1;
+			uint64_t u64_bit_5 : 1;
+			uint64_t u64_bit_6 : 1;
+			uint64_t u64_bit_7 : 1;
+			uint64_t u64_bit_8 : 1;
+			uint64_t u64_bit_9 : 1;
+			uint64_t u64_bit_10 : 1;
+			uint64_t u64_bit_11 : 1;
+			uint64_t u64_bit_12 : 1;
+			uint64_t u64_bit_13 : 1;
+			uint64_t u64_bit_14 : 1;
+			uint64_t u64_bit_15 : 1;
+			uint64_t u64_bit_16 : 1;
+			uint64_t u64_bit_17 : 1;
+			uint64_t u64_bit_18 : 1;
+			uint64_t u64_bit_19 : 1;
+			uint64_t u64_bit_20 : 1;
+			uint64_t u64_bit_21 : 1;
+			uint64_t u64_bit_22 : 1;
+			uint64_t u64_bit_23 : 1;
+			uint64_t u64_bit_24 : 1;
+			uint64_t u64_bit_25 : 1;
+			uint64_t u64_bit_26 : 1;
+			uint64_t u64_bit_27 : 1;
+			uint64_t u64_bit_28 : 1;
+			uint64_t u64_bit_29 : 1;
+			uint64_t u64_bit_30 : 1;
+			uint64_t u64_bit_31 : 1;
+			uint64_t u64_bit_32 : 1;
+			uint64_t u64_bit_33 : 1;
+			uint64_t u64_bit_34 : 1;
+			uint64_t u64_bit_35 : 1;
+			uint64_t u64_bit_36 : 1;
+			uint64_t u64_bit_37 : 1;
+			uint64_t u64_bit_38 : 1;
+			uint64_t u64_bit_39 : 1;
+			uint64_t u64_bit_40 : 1;
+			uint64_t u64_bit_41 : 1;
+			uint64_t u64_bit_42 : 1;
+			uint64_t u64_bit_43 : 1;
+			uint64_t u64_bit_44 : 1;
+			uint64_t u64_bit_45 : 1;
+			uint64_t u64_bit_46 : 1;
+			uint64_t u64_bit_47 : 1;
+			uint64_t u64_bit_48 : 1;
+			uint64_t u64_bit_49 : 1;
+			uint64_t u64_bit_50 : 1;
+			uint64_t u64_bit_51 : 1;
+			uint64_t u64_bit_52 : 1;
+			uint64_t u64_bit_53 : 1;
+			uint64_t u64_bit_54 : 1;
+			uint64_t u64_bit_55 : 1;
+			uint64_t u64_bit_56 : 1;
+			uint64_t u64_bit_57 : 1;
+			uint64_t u64_bit_58 : 1;
+			uint64_t u64_bit_59 : 1;
+			uint64_t u64_bit_60 : 1;
+			uint64_t u64_bit_61 : 1;
+			uint64_t u64_bit_62 : 1;
+			uint64_t u64_bit_63 : 1;
+		};
+	};
+};
+
+struct bitfield masks[] = {
+	{.u64_bit_0 = 1},
+	{.u64_bit_1 = 1},
+	{.u64_bit_2 = 1},
+	{.u64_bit_3 = 1},
+	{.u64_bit_4 = 1},
+	{.u64_bit_5 = 1},
+	{.u64_bit_6 = 1},
+	{.u64_bit_7 = 1},
+	{.u64_bit_8 = 1},
+	{.u64_bit_9 = 1},
+	{.u64_bit_10 = 1},
+	{.u64_bit_11 = 1},
+	{.u64_bit_12 = 1},
+	{.u64_bit_13 = 1},
+	{.u64_bit_14 = 1},
+	{.u64_bit_15 = 1},
+	{.u64_bit_16 = 1},
+	{.u64_bit_17 = 1},
+	{.u64_bit_18 = 1},
+	{.u64_bit_19 = 1},
+	{.u64_bit_20 = 1},
+	{.u64_bit_21 = 1},
+	{.u64_bit_22 = 1},
+	{.u64_bit_23 = 1},
+	{.u64_bit_24 = 1},
+	{.u64_bit_25 = 1},
+	{.u64_bit_26 = 1},
+	{.u64_bit_27 = 1},
+	{.u64_bit_28 = 1},
+	{.u64_bit_29 = 1},
+	{.u64_bit_30 = 1},
+	{.u64_bit_31 = 1},
+	{.u64_bit_32 = 1},
+	{.u64_bit_33 = 1},
+	{.u64_bit_34 = 1},
+	{.u64_bit_35 = 1},
+	{.u64_bit_36 = 1},
+	{.u64_bit_37 = 1},
+	{.u64_bit_38 = 1},
+	{.u64_bit_39 = 1},
+	{.u64_bit_40 = 1},
+	{.u64_bit_41 = 1},
+	{.u64_bit_42 = 1},
+	{.u64_bit_43 = 1},
+	{.u64_bit_44 = 1},
+	{.u64_bit_45 = 1},
+	{.u64_bit_46 = 1},
+	{.u64_bit_47 = 1},
+	{.u64_bit_48 = 1},
+	{.u64_bit_49 = 1},
+	{.u64_bit_50 = 1},
+	{.u64_bit_51 = 1},
+	{.u64_bit_52 = 1},
+	{.u64_bit_53 = 1},
+	{.u64_bit_54 = 1},
+	{.u64_bit_55 = 1},
+	{.u64_bit_56 = 1},
+	{.u64_bit_57 = 1},
+	{.u64_bit_58 = 1},
+	{.u64_bit_59 = 1},
+	{.u64_bit_60 = 1},
+	{.u64_bit_61 = 1},
+	{.u64_bit_62 = 1},
+	{.u64_bit_63 = 1}
+};
+
+int main(int argc, char **argv) {
+	struct bitfield *mask_ptr = &masks[0];
+	return mask_ptr->val;
+}
+
+`
diff --git a/unix/linux/types.go b/unix/linux/types.go
index 186a98f..7621d2e 100644
--- a/unix/linux/types.go
+++ b/unix/linux/types.go
@@ -68,6 +68,9 @@
 #include <linux/cgroupstats.h>
 #include <linux/genetlink.h>
 
+// abi/abi.h generated by mkall.go.
+#include "abi/abi.h"
+
 // On mips64, the glibc stat and kernel stat do not agree
 #if (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64)
 
@@ -694,3 +697,75 @@
 	BDADDR_LE_PUBLIC = C.BDADDR_LE_PUBLIC
 	BDADDR_LE_RANDOM = C.BDADDR_LE_RANDOM
 )
+
+// Platform ABI and calling convention
+
+// Bit field masks for interoperability with C code that uses bit fields.
+// Each mask corresponds to a single bit set - bit field behavior can be replicated by combining
+// the masks with bitwise OR.
+const (
+	CBitFieldMaskBit0  = C.BITFIELD_MASK_0
+	CBitFieldMaskBit1  = C.BITFIELD_MASK_1
+	CBitFieldMaskBit2  = C.BITFIELD_MASK_2
+	CBitFieldMaskBit3  = C.BITFIELD_MASK_3
+	CBitFieldMaskBit4  = C.BITFIELD_MASK_4
+	CBitFieldMaskBit5  = C.BITFIELD_MASK_5
+	CBitFieldMaskBit6  = C.BITFIELD_MASK_6
+	CBitFieldMaskBit7  = C.BITFIELD_MASK_7
+	CBitFieldMaskBit8  = C.BITFIELD_MASK_8
+	CBitFieldMaskBit9  = C.BITFIELD_MASK_9
+	CBitFieldMaskBit10 = C.BITFIELD_MASK_10
+	CBitFieldMaskBit11 = C.BITFIELD_MASK_11
+	CBitFieldMaskBit12 = C.BITFIELD_MASK_12
+	CBitFieldMaskBit13 = C.BITFIELD_MASK_13
+	CBitFieldMaskBit14 = C.BITFIELD_MASK_14
+	CBitFieldMaskBit15 = C.BITFIELD_MASK_15
+	CBitFieldMaskBit16 = C.BITFIELD_MASK_16
+	CBitFieldMaskBit17 = C.BITFIELD_MASK_17
+	CBitFieldMaskBit18 = C.BITFIELD_MASK_18
+	CBitFieldMaskBit19 = C.BITFIELD_MASK_19
+	CBitFieldMaskBit20 = C.BITFIELD_MASK_20
+	CBitFieldMaskBit21 = C.BITFIELD_MASK_21
+	CBitFieldMaskBit22 = C.BITFIELD_MASK_22
+	CBitFieldMaskBit23 = C.BITFIELD_MASK_23
+	CBitFieldMaskBit24 = C.BITFIELD_MASK_24
+	CBitFieldMaskBit25 = C.BITFIELD_MASK_25
+	CBitFieldMaskBit26 = C.BITFIELD_MASK_26
+	CBitFieldMaskBit27 = C.BITFIELD_MASK_27
+	CBitFieldMaskBit28 = C.BITFIELD_MASK_28
+	CBitFieldMaskBit29 = C.BITFIELD_MASK_29
+	CBitFieldMaskBit30 = C.BITFIELD_MASK_30
+	CBitFieldMaskBit31 = C.BITFIELD_MASK_31
+	CBitFieldMaskBit32 = C.BITFIELD_MASK_32
+	CBitFieldMaskBit33 = C.BITFIELD_MASK_33
+	CBitFieldMaskBit34 = C.BITFIELD_MASK_34
+	CBitFieldMaskBit35 = C.BITFIELD_MASK_35
+	CBitFieldMaskBit36 = C.BITFIELD_MASK_36
+	CBitFieldMaskBit37 = C.BITFIELD_MASK_37
+	CBitFieldMaskBit38 = C.BITFIELD_MASK_38
+	CBitFieldMaskBit39 = C.BITFIELD_MASK_39
+	CBitFieldMaskBit40 = C.BITFIELD_MASK_40
+	CBitFieldMaskBit41 = C.BITFIELD_MASK_41
+	CBitFieldMaskBit42 = C.BITFIELD_MASK_42
+	CBitFieldMaskBit43 = C.BITFIELD_MASK_43
+	CBitFieldMaskBit44 = C.BITFIELD_MASK_44
+	CBitFieldMaskBit45 = C.BITFIELD_MASK_45
+	CBitFieldMaskBit46 = C.BITFIELD_MASK_46
+	CBitFieldMaskBit47 = C.BITFIELD_MASK_47
+	CBitFieldMaskBit48 = C.BITFIELD_MASK_48
+	CBitFieldMaskBit49 = C.BITFIELD_MASK_49
+	CBitFieldMaskBit50 = C.BITFIELD_MASK_50
+	CBitFieldMaskBit51 = C.BITFIELD_MASK_51
+	CBitFieldMaskBit52 = C.BITFIELD_MASK_52
+	CBitFieldMaskBit53 = C.BITFIELD_MASK_53
+	CBitFieldMaskBit54 = C.BITFIELD_MASK_54
+	CBitFieldMaskBit55 = C.BITFIELD_MASK_55
+	CBitFieldMaskBit56 = C.BITFIELD_MASK_56
+	CBitFieldMaskBit57 = C.BITFIELD_MASK_57
+	CBitFieldMaskBit58 = C.BITFIELD_MASK_58
+	CBitFieldMaskBit59 = C.BITFIELD_MASK_59
+	CBitFieldMaskBit60 = C.BITFIELD_MASK_60
+	CBitFieldMaskBit61 = C.BITFIELD_MASK_61
+	CBitFieldMaskBit62 = C.BITFIELD_MASK_62
+	CBitFieldMaskBit63 = C.BITFIELD_MASK_63
+)
diff --git a/unix/ztypes_linux_386.go b/unix/ztypes_linux_386.go
index 3c56b20..8a20574 100644
--- a/unix/ztypes_linux_386.go
+++ b/unix/ztypes_linux_386.go
@@ -895,3 +895,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_amd64.go b/unix/ztypes_linux_amd64.go
index 92f1c8f..ccf8137 100644
--- a/unix/ztypes_linux_amd64.go
+++ b/unix/ztypes_linux_amd64.go
@@ -913,3 +913,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_arm.go b/unix/ztypes_linux_arm.go
index cee5459..d7b05e5 100644
--- a/unix/ztypes_linux_arm.go
+++ b/unix/ztypes_linux_arm.go
@@ -884,3 +884,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_arm64.go b/unix/ztypes_linux_arm64.go
index 5ce7cfe..27d8b40 100644
--- a/unix/ztypes_linux_arm64.go
+++ b/unix/ztypes_linux_arm64.go
@@ -892,3 +892,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_mips.go b/unix/ztypes_linux_mips.go
index 2860b3e..7d451aa 100644
--- a/unix/ztypes_linux_mips.go
+++ b/unix/ztypes_linux_mips.go
@@ -889,3 +889,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x8000000000000000
+	CBitFieldMaskBit1  = 0x4000000000000000
+	CBitFieldMaskBit2  = 0x2000000000000000
+	CBitFieldMaskBit3  = 0x1000000000000000
+	CBitFieldMaskBit4  = 0x800000000000000
+	CBitFieldMaskBit5  = 0x400000000000000
+	CBitFieldMaskBit6  = 0x200000000000000
+	CBitFieldMaskBit7  = 0x100000000000000
+	CBitFieldMaskBit8  = 0x80000000000000
+	CBitFieldMaskBit9  = 0x40000000000000
+	CBitFieldMaskBit10 = 0x20000000000000
+	CBitFieldMaskBit11 = 0x10000000000000
+	CBitFieldMaskBit12 = 0x8000000000000
+	CBitFieldMaskBit13 = 0x4000000000000
+	CBitFieldMaskBit14 = 0x2000000000000
+	CBitFieldMaskBit15 = 0x1000000000000
+	CBitFieldMaskBit16 = 0x800000000000
+	CBitFieldMaskBit17 = 0x400000000000
+	CBitFieldMaskBit18 = 0x200000000000
+	CBitFieldMaskBit19 = 0x100000000000
+	CBitFieldMaskBit20 = 0x80000000000
+	CBitFieldMaskBit21 = 0x40000000000
+	CBitFieldMaskBit22 = 0x20000000000
+	CBitFieldMaskBit23 = 0x10000000000
+	CBitFieldMaskBit24 = 0x8000000000
+	CBitFieldMaskBit25 = 0x4000000000
+	CBitFieldMaskBit26 = 0x2000000000
+	CBitFieldMaskBit27 = 0x1000000000
+	CBitFieldMaskBit28 = 0x800000000
+	CBitFieldMaskBit29 = 0x400000000
+	CBitFieldMaskBit30 = 0x200000000
+	CBitFieldMaskBit31 = 0x100000000
+	CBitFieldMaskBit32 = 0x80000000
+	CBitFieldMaskBit33 = 0x40000000
+	CBitFieldMaskBit34 = 0x20000000
+	CBitFieldMaskBit35 = 0x10000000
+	CBitFieldMaskBit36 = 0x8000000
+	CBitFieldMaskBit37 = 0x4000000
+	CBitFieldMaskBit38 = 0x2000000
+	CBitFieldMaskBit39 = 0x1000000
+	CBitFieldMaskBit40 = 0x800000
+	CBitFieldMaskBit41 = 0x400000
+	CBitFieldMaskBit42 = 0x200000
+	CBitFieldMaskBit43 = 0x100000
+	CBitFieldMaskBit44 = 0x80000
+	CBitFieldMaskBit45 = 0x40000
+	CBitFieldMaskBit46 = 0x20000
+	CBitFieldMaskBit47 = 0x10000
+	CBitFieldMaskBit48 = 0x8000
+	CBitFieldMaskBit49 = 0x4000
+	CBitFieldMaskBit50 = 0x2000
+	CBitFieldMaskBit51 = 0x1000
+	CBitFieldMaskBit52 = 0x800
+	CBitFieldMaskBit53 = 0x400
+	CBitFieldMaskBit54 = 0x200
+	CBitFieldMaskBit55 = 0x100
+	CBitFieldMaskBit56 = 0x80
+	CBitFieldMaskBit57 = 0x40
+	CBitFieldMaskBit58 = 0x20
+	CBitFieldMaskBit59 = 0x10
+	CBitFieldMaskBit60 = 0x8
+	CBitFieldMaskBit61 = 0x4
+	CBitFieldMaskBit62 = 0x2
+	CBitFieldMaskBit63 = 0x1
+)
diff --git a/unix/ztypes_linux_mips64.go b/unix/ztypes_linux_mips64.go
index 17b881c..cbe9230 100644
--- a/unix/ztypes_linux_mips64.go
+++ b/unix/ztypes_linux_mips64.go
@@ -894,3 +894,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x8000000000000000
+	CBitFieldMaskBit1  = 0x4000000000000000
+	CBitFieldMaskBit2  = 0x2000000000000000
+	CBitFieldMaskBit3  = 0x1000000000000000
+	CBitFieldMaskBit4  = 0x800000000000000
+	CBitFieldMaskBit5  = 0x400000000000000
+	CBitFieldMaskBit6  = 0x200000000000000
+	CBitFieldMaskBit7  = 0x100000000000000
+	CBitFieldMaskBit8  = 0x80000000000000
+	CBitFieldMaskBit9  = 0x40000000000000
+	CBitFieldMaskBit10 = 0x20000000000000
+	CBitFieldMaskBit11 = 0x10000000000000
+	CBitFieldMaskBit12 = 0x8000000000000
+	CBitFieldMaskBit13 = 0x4000000000000
+	CBitFieldMaskBit14 = 0x2000000000000
+	CBitFieldMaskBit15 = 0x1000000000000
+	CBitFieldMaskBit16 = 0x800000000000
+	CBitFieldMaskBit17 = 0x400000000000
+	CBitFieldMaskBit18 = 0x200000000000
+	CBitFieldMaskBit19 = 0x100000000000
+	CBitFieldMaskBit20 = 0x80000000000
+	CBitFieldMaskBit21 = 0x40000000000
+	CBitFieldMaskBit22 = 0x20000000000
+	CBitFieldMaskBit23 = 0x10000000000
+	CBitFieldMaskBit24 = 0x8000000000
+	CBitFieldMaskBit25 = 0x4000000000
+	CBitFieldMaskBit26 = 0x2000000000
+	CBitFieldMaskBit27 = 0x1000000000
+	CBitFieldMaskBit28 = 0x800000000
+	CBitFieldMaskBit29 = 0x400000000
+	CBitFieldMaskBit30 = 0x200000000
+	CBitFieldMaskBit31 = 0x100000000
+	CBitFieldMaskBit32 = 0x80000000
+	CBitFieldMaskBit33 = 0x40000000
+	CBitFieldMaskBit34 = 0x20000000
+	CBitFieldMaskBit35 = 0x10000000
+	CBitFieldMaskBit36 = 0x8000000
+	CBitFieldMaskBit37 = 0x4000000
+	CBitFieldMaskBit38 = 0x2000000
+	CBitFieldMaskBit39 = 0x1000000
+	CBitFieldMaskBit40 = 0x800000
+	CBitFieldMaskBit41 = 0x400000
+	CBitFieldMaskBit42 = 0x200000
+	CBitFieldMaskBit43 = 0x100000
+	CBitFieldMaskBit44 = 0x80000
+	CBitFieldMaskBit45 = 0x40000
+	CBitFieldMaskBit46 = 0x20000
+	CBitFieldMaskBit47 = 0x10000
+	CBitFieldMaskBit48 = 0x8000
+	CBitFieldMaskBit49 = 0x4000
+	CBitFieldMaskBit50 = 0x2000
+	CBitFieldMaskBit51 = 0x1000
+	CBitFieldMaskBit52 = 0x800
+	CBitFieldMaskBit53 = 0x400
+	CBitFieldMaskBit54 = 0x200
+	CBitFieldMaskBit55 = 0x100
+	CBitFieldMaskBit56 = 0x80
+	CBitFieldMaskBit57 = 0x40
+	CBitFieldMaskBit58 = 0x20
+	CBitFieldMaskBit59 = 0x10
+	CBitFieldMaskBit60 = 0x8
+	CBitFieldMaskBit61 = 0x4
+	CBitFieldMaskBit62 = 0x2
+	CBitFieldMaskBit63 = 0x1
+)
diff --git a/unix/ztypes_linux_mips64le.go b/unix/ztypes_linux_mips64le.go
index ec802dc..990468f 100644
--- a/unix/ztypes_linux_mips64le.go
+++ b/unix/ztypes_linux_mips64le.go
@@ -894,3 +894,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_mipsle.go b/unix/ztypes_linux_mipsle.go
index 4a99648..3433a8f6 100644
--- a/unix/ztypes_linux_mipsle.go
+++ b/unix/ztypes_linux_mipsle.go
@@ -889,3 +889,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_ppc64.go b/unix/ztypes_linux_ppc64.go
index 63a0dbe..5748d80 100644
--- a/unix/ztypes_linux_ppc64.go
+++ b/unix/ztypes_linux_ppc64.go
@@ -902,3 +902,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x8000000000000000
+	CBitFieldMaskBit1  = 0x4000000000000000
+	CBitFieldMaskBit2  = 0x2000000000000000
+	CBitFieldMaskBit3  = 0x1000000000000000
+	CBitFieldMaskBit4  = 0x800000000000000
+	CBitFieldMaskBit5  = 0x400000000000000
+	CBitFieldMaskBit6  = 0x200000000000000
+	CBitFieldMaskBit7  = 0x100000000000000
+	CBitFieldMaskBit8  = 0x80000000000000
+	CBitFieldMaskBit9  = 0x40000000000000
+	CBitFieldMaskBit10 = 0x20000000000000
+	CBitFieldMaskBit11 = 0x10000000000000
+	CBitFieldMaskBit12 = 0x8000000000000
+	CBitFieldMaskBit13 = 0x4000000000000
+	CBitFieldMaskBit14 = 0x2000000000000
+	CBitFieldMaskBit15 = 0x1000000000000
+	CBitFieldMaskBit16 = 0x800000000000
+	CBitFieldMaskBit17 = 0x400000000000
+	CBitFieldMaskBit18 = 0x200000000000
+	CBitFieldMaskBit19 = 0x100000000000
+	CBitFieldMaskBit20 = 0x80000000000
+	CBitFieldMaskBit21 = 0x40000000000
+	CBitFieldMaskBit22 = 0x20000000000
+	CBitFieldMaskBit23 = 0x10000000000
+	CBitFieldMaskBit24 = 0x8000000000
+	CBitFieldMaskBit25 = 0x4000000000
+	CBitFieldMaskBit26 = 0x2000000000
+	CBitFieldMaskBit27 = 0x1000000000
+	CBitFieldMaskBit28 = 0x800000000
+	CBitFieldMaskBit29 = 0x400000000
+	CBitFieldMaskBit30 = 0x200000000
+	CBitFieldMaskBit31 = 0x100000000
+	CBitFieldMaskBit32 = 0x80000000
+	CBitFieldMaskBit33 = 0x40000000
+	CBitFieldMaskBit34 = 0x20000000
+	CBitFieldMaskBit35 = 0x10000000
+	CBitFieldMaskBit36 = 0x8000000
+	CBitFieldMaskBit37 = 0x4000000
+	CBitFieldMaskBit38 = 0x2000000
+	CBitFieldMaskBit39 = 0x1000000
+	CBitFieldMaskBit40 = 0x800000
+	CBitFieldMaskBit41 = 0x400000
+	CBitFieldMaskBit42 = 0x200000
+	CBitFieldMaskBit43 = 0x100000
+	CBitFieldMaskBit44 = 0x80000
+	CBitFieldMaskBit45 = 0x40000
+	CBitFieldMaskBit46 = 0x20000
+	CBitFieldMaskBit47 = 0x10000
+	CBitFieldMaskBit48 = 0x8000
+	CBitFieldMaskBit49 = 0x4000
+	CBitFieldMaskBit50 = 0x2000
+	CBitFieldMaskBit51 = 0x1000
+	CBitFieldMaskBit52 = 0x800
+	CBitFieldMaskBit53 = 0x400
+	CBitFieldMaskBit54 = 0x200
+	CBitFieldMaskBit55 = 0x100
+	CBitFieldMaskBit56 = 0x80
+	CBitFieldMaskBit57 = 0x40
+	CBitFieldMaskBit58 = 0x20
+	CBitFieldMaskBit59 = 0x10
+	CBitFieldMaskBit60 = 0x8
+	CBitFieldMaskBit61 = 0x4
+	CBitFieldMaskBit62 = 0x2
+	CBitFieldMaskBit63 = 0x1
+)
diff --git a/unix/ztypes_linux_ppc64le.go b/unix/ztypes_linux_ppc64le.go
index f20a635..ca54d44 100644
--- a/unix/ztypes_linux_ppc64le.go
+++ b/unix/ztypes_linux_ppc64le.go
@@ -902,3 +902,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x1
+	CBitFieldMaskBit1  = 0x2
+	CBitFieldMaskBit2  = 0x4
+	CBitFieldMaskBit3  = 0x8
+	CBitFieldMaskBit4  = 0x10
+	CBitFieldMaskBit5  = 0x20
+	CBitFieldMaskBit6  = 0x40
+	CBitFieldMaskBit7  = 0x80
+	CBitFieldMaskBit8  = 0x100
+	CBitFieldMaskBit9  = 0x200
+	CBitFieldMaskBit10 = 0x400
+	CBitFieldMaskBit11 = 0x800
+	CBitFieldMaskBit12 = 0x1000
+	CBitFieldMaskBit13 = 0x2000
+	CBitFieldMaskBit14 = 0x4000
+	CBitFieldMaskBit15 = 0x8000
+	CBitFieldMaskBit16 = 0x10000
+	CBitFieldMaskBit17 = 0x20000
+	CBitFieldMaskBit18 = 0x40000
+	CBitFieldMaskBit19 = 0x80000
+	CBitFieldMaskBit20 = 0x100000
+	CBitFieldMaskBit21 = 0x200000
+	CBitFieldMaskBit22 = 0x400000
+	CBitFieldMaskBit23 = 0x800000
+	CBitFieldMaskBit24 = 0x1000000
+	CBitFieldMaskBit25 = 0x2000000
+	CBitFieldMaskBit26 = 0x4000000
+	CBitFieldMaskBit27 = 0x8000000
+	CBitFieldMaskBit28 = 0x10000000
+	CBitFieldMaskBit29 = 0x20000000
+	CBitFieldMaskBit30 = 0x40000000
+	CBitFieldMaskBit31 = 0x80000000
+	CBitFieldMaskBit32 = 0x100000000
+	CBitFieldMaskBit33 = 0x200000000
+	CBitFieldMaskBit34 = 0x400000000
+	CBitFieldMaskBit35 = 0x800000000
+	CBitFieldMaskBit36 = 0x1000000000
+	CBitFieldMaskBit37 = 0x2000000000
+	CBitFieldMaskBit38 = 0x4000000000
+	CBitFieldMaskBit39 = 0x8000000000
+	CBitFieldMaskBit40 = 0x10000000000
+	CBitFieldMaskBit41 = 0x20000000000
+	CBitFieldMaskBit42 = 0x40000000000
+	CBitFieldMaskBit43 = 0x80000000000
+	CBitFieldMaskBit44 = 0x100000000000
+	CBitFieldMaskBit45 = 0x200000000000
+	CBitFieldMaskBit46 = 0x400000000000
+	CBitFieldMaskBit47 = 0x800000000000
+	CBitFieldMaskBit48 = 0x1000000000000
+	CBitFieldMaskBit49 = 0x2000000000000
+	CBitFieldMaskBit50 = 0x4000000000000
+	CBitFieldMaskBit51 = 0x8000000000000
+	CBitFieldMaskBit52 = 0x10000000000000
+	CBitFieldMaskBit53 = 0x20000000000000
+	CBitFieldMaskBit54 = 0x40000000000000
+	CBitFieldMaskBit55 = 0x80000000000000
+	CBitFieldMaskBit56 = 0x100000000000000
+	CBitFieldMaskBit57 = 0x200000000000000
+	CBitFieldMaskBit58 = 0x400000000000000
+	CBitFieldMaskBit59 = 0x800000000000000
+	CBitFieldMaskBit60 = 0x1000000000000000
+	CBitFieldMaskBit61 = 0x2000000000000000
+	CBitFieldMaskBit62 = 0x4000000000000000
+	CBitFieldMaskBit63 = 0x8000000000000000
+)
diff --git a/unix/ztypes_linux_s390x.go b/unix/ztypes_linux_s390x.go
index 30dc105..1dccea9 100644
--- a/unix/ztypes_linux_s390x.go
+++ b/unix/ztypes_linux_s390x.go
@@ -919,3 +919,70 @@
 	BDADDR_LE_PUBLIC = 0x1
 	BDADDR_LE_RANDOM = 0x2
 )
+
+const (
+	CBitFieldMaskBit0  = 0x8000000000000000
+	CBitFieldMaskBit1  = 0x4000000000000000
+	CBitFieldMaskBit2  = 0x2000000000000000
+	CBitFieldMaskBit3  = 0x1000000000000000
+	CBitFieldMaskBit4  = 0x800000000000000
+	CBitFieldMaskBit5  = 0x400000000000000
+	CBitFieldMaskBit6  = 0x200000000000000
+	CBitFieldMaskBit7  = 0x100000000000000
+	CBitFieldMaskBit8  = 0x80000000000000
+	CBitFieldMaskBit9  = 0x40000000000000
+	CBitFieldMaskBit10 = 0x20000000000000
+	CBitFieldMaskBit11 = 0x10000000000000
+	CBitFieldMaskBit12 = 0x8000000000000
+	CBitFieldMaskBit13 = 0x4000000000000
+	CBitFieldMaskBit14 = 0x2000000000000
+	CBitFieldMaskBit15 = 0x1000000000000
+	CBitFieldMaskBit16 = 0x800000000000
+	CBitFieldMaskBit17 = 0x400000000000
+	CBitFieldMaskBit18 = 0x200000000000
+	CBitFieldMaskBit19 = 0x100000000000
+	CBitFieldMaskBit20 = 0x80000000000
+	CBitFieldMaskBit21 = 0x40000000000
+	CBitFieldMaskBit22 = 0x20000000000
+	CBitFieldMaskBit23 = 0x10000000000
+	CBitFieldMaskBit24 = 0x8000000000
+	CBitFieldMaskBit25 = 0x4000000000
+	CBitFieldMaskBit26 = 0x2000000000
+	CBitFieldMaskBit27 = 0x1000000000
+	CBitFieldMaskBit28 = 0x800000000
+	CBitFieldMaskBit29 = 0x400000000
+	CBitFieldMaskBit30 = 0x200000000
+	CBitFieldMaskBit31 = 0x100000000
+	CBitFieldMaskBit32 = 0x80000000
+	CBitFieldMaskBit33 = 0x40000000
+	CBitFieldMaskBit34 = 0x20000000
+	CBitFieldMaskBit35 = 0x10000000
+	CBitFieldMaskBit36 = 0x8000000
+	CBitFieldMaskBit37 = 0x4000000
+	CBitFieldMaskBit38 = 0x2000000
+	CBitFieldMaskBit39 = 0x1000000
+	CBitFieldMaskBit40 = 0x800000
+	CBitFieldMaskBit41 = 0x400000
+	CBitFieldMaskBit42 = 0x200000
+	CBitFieldMaskBit43 = 0x100000
+	CBitFieldMaskBit44 = 0x80000
+	CBitFieldMaskBit45 = 0x40000
+	CBitFieldMaskBit46 = 0x20000
+	CBitFieldMaskBit47 = 0x10000
+	CBitFieldMaskBit48 = 0x8000
+	CBitFieldMaskBit49 = 0x4000
+	CBitFieldMaskBit50 = 0x2000
+	CBitFieldMaskBit51 = 0x1000
+	CBitFieldMaskBit52 = 0x800
+	CBitFieldMaskBit53 = 0x400
+	CBitFieldMaskBit54 = 0x200
+	CBitFieldMaskBit55 = 0x100
+	CBitFieldMaskBit56 = 0x80
+	CBitFieldMaskBit57 = 0x40
+	CBitFieldMaskBit58 = 0x20
+	CBitFieldMaskBit59 = 0x10
+	CBitFieldMaskBit60 = 0x8
+	CBitFieldMaskBit61 = 0x4
+	CBitFieldMaskBit62 = 0x2
+	CBitFieldMaskBit63 = 0x1
+)