diff --git a/lib/std/bloom_filter.zig b/lib/std/bloom_filter.zig index f12f0d86afe8aa6cefdef7fc8f58c152a5cdc7d3..80e168b8fda42aacf8a0b48f4fee04c438f6f476 100644 --- a/lib/std/bloom_filter.zig +++ b/lib/std/bloom_filter.zig @@ -160,6 +160,9 @@ fn hashFunc(out: []u8, Ki: usize, in: []const u8) void { } test "std.BloomFilter" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + inline for ([_]type{ bool, u1, u2, u3, u4 }) |Cell| { const emptyCell = if (Cell == bool) false else @as(Cell, 0); const BF = BloomFilter(128 * 8, 8, Cell, builtin.endian, hashFunc); diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig index be789d89538116224218c463f3b5d32b7fb2909f..2bfbfe32f0098abc26c71475cb42e28303e2e8e5 100644 --- a/lib/std/crypto/gimli.zig +++ b/lib/std/crypto/gimli.zig @@ -162,6 +162,9 @@ pub fn hash(out: []u8, in: []const u8) void { } test "hash" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + // a test vector (30) from NIST KAT submission. var msg: [58 / 2]u8 = undefined; try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C"); @@ -307,6 +310,9 @@ pub const Aead = struct { }; test "cipher" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + var key: [32]u8 = undefined; try std.fmt.hexToBytes(&key, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); var nonce: [16]u8 = undefined; diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index dca2a591713833089053f498132a2e200a6e681d..baad8046032c72c319258f4a0f5ae32217f14cc4 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -1661,7 +1661,7 @@ test "positional/alignment/width/precision" { } test "vector" { - if (builtin.arch == .mipsel) { + if (builtin.arch == .mipsel or builtin.arch == .mips) { // https://github.com/ziglang/zig/issues/3317 return error.SkipZigTest; } diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig index b5d6c528a5022bda25880308cc9cc249e462df30..7ecf25eceb5c48fe14b3e2c4106753e3f997f786 100644 --- a/lib/std/hash/auto_hash.zig +++ b/lib/std/hash/auto_hash.zig @@ -357,7 +357,7 @@ test "testHash union" { test "testHash vector" { // Disabled because of #3317 - if (@import("builtin").arch == .mipsel) return error.SkipZigTest; + if (@import("builtin").arch == .mipsel or @import("builtin").arch == .mips) return error.SkipZigTest; const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 }; const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 }; diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 4b3e082f0c9796d760c785881dff82140665c145..47cc2f91e976dbeb0e73c569e8cc7e32fac166b4 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -463,6 +463,9 @@ test "basic hash map usage" { } test "iterator hash map" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + var reset_map = AutoHashMap(i32, i32).init(std.testing.allocator); defer reset_map.deinit(); diff --git a/lib/std/io/test.zig b/lib/std/io/test.zig index d8ee9612ea8da5bb165154bcea5fb9f62583e542..32a317d0299070128af166e35ec7b9856008b275 100644 --- a/lib/std/io/test.zig +++ b/lib/std/io/test.zig @@ -126,6 +126,9 @@ test "File seek ops" { } test "setEndPos" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + const tmp_file_name = "temp_test_file.txt"; var file = try fs.cwd().createFile(tmp_file_name, .{}); defer { diff --git a/lib/std/json.zig b/lib/std/json.zig index 1784f44a4d2a588360fa90406a4a59a5b5b24074..fcda3fd835d53776bb9b6cada886c5b45f2a860f 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -2249,6 +2249,9 @@ test "integer after float has proper type" { } test "escaped characters" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena_allocator.deinit(); const input = @@ -2281,6 +2284,9 @@ test "escaped characters" { } test "string copy option" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + const input = \\{ \\ "noescape": "aą😂", diff --git a/lib/std/json/test.zig b/lib/std/json/test.zig index 5d46b75a48ed43b2dc68f6c45da6e5f3695ae2c1..ed7454cce333bb1bc767d032c6eefb74b5bd2735 100644 --- a/lib/std/json/test.zig +++ b/lib/std/json/test.zig @@ -332,12 +332,18 @@ test "y_string_1_2_3_bytes_UTF-8_sequences" { } test "y_string_accepted_surrogate_pair" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uD801\udc37"] ); } test "y_string_accepted_surrogate_pairs" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\ud83d\ude39\ud83d\udc8d"] ); @@ -404,6 +410,9 @@ test "y_string_in_array_with_leading_space" { } test "y_string_last_surrogates_1_and_2" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uDBFF\uDFFF"] ); @@ -464,6 +473,9 @@ test "y_string_space" { } test "y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uD834\uDd1e"] ); @@ -506,60 +518,90 @@ test "y_string_unescaped_char_delete" { } test "y_string_unicode_2" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["⍂㈴⍂"] ); } test "y_string_unicodeEscapedBackslash" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\u005C"] ); } test "y_string_unicode_escaped_double_quote" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\u0022"] ); } test "y_string_unicode" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uA66D"] ); } test "y_string_unicode_U+10FFFE_nonchar" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uDBFF\uDFFE"] ); } test "y_string_unicode_U+1FFFE_nonchar" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uD83F\uDFFE"] ); } test "y_string_unicode_U+200B_ZERO_WIDTH_SPACE" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\u200B"] ); } test "y_string_unicode_U+2064_invisible_plus" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\u2064"] ); } test "y_string_unicode_U+FDD0_nonchar" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uFDD0"] ); } test "y_string_unicode_U+FFFE_nonchar" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + ok( \\["\uFFFE"] ); @@ -1811,42 +1853,63 @@ test "i_object_key_lone_2nd_surrogate" { } test "i_string_1st_surrogate_but_2nd_missing" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uDADA"] ); } test "i_string_1st_valid_surrogate_2nd_invalid" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uD888\u1234"] ); } test "i_string_incomplete_surrogate_and_escape_valid" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uD800\n"] ); } test "i_string_incomplete_surrogate_pair" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uDd1ea"] ); } test "i_string_incomplete_surrogates_escape_valid" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uD800\uD800\n"] ); } test "i_string_invalid_lonely_surrogate" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\ud800"] ); } test "i_string_invalid_surrogate" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\ud800abc"] ); @@ -1859,6 +1922,9 @@ test "i_string_invalid_utf-8" { } test "i_string_inverted_surrogates_U+1D11E" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uDd1e\uD834"] ); @@ -1871,6 +1937,9 @@ test "i_string_iso_latin_1" { } test "i_string_lone_second_surrogate" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + anyStreamingErrNonStreaming( \\["\uDFAA"] ); diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index 6f4e9b803dcbeffd338dee836acdfbc1a6f57f99..1d2a9570363461bb6880191596e1ef07809e330f 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -14,7 +14,7 @@ pub usingnamespace switch (builtin.arch) { .aarch64 => @import("linux/arm64.zig"), .arm => @import("linux/arm-eabi.zig"), .riscv64 => @import("linux/riscv64.zig"), - .mipsel => @import("linux/mipsel.zig"), + .mips, .mipsel => @import("linux/mips.zig"), else => struct {}, }; diff --git a/lib/std/os/bits/linux/mips.zig b/lib/std/os/bits/linux/mips.zig new file mode 100644 index 0000000000000000000000000000000000000000..5946e821ad9fdb4748b50178bc49486643eab1aa --- /dev/null +++ b/lib/std/os/bits/linux/mips.zig @@ -0,0 +1,543 @@ +const std = @import("../../../std.zig"); +const linux = std.os.linux; +const socklen_t = linux.socklen_t; +const iovec = linux.iovec; +const iovec_const = linux.iovec_const; +const uid_t = linux.uid_t; +const gid_t = linux.gid_t; +const pid_t = linux.pid_t; + +pub const SYS = extern enum(usize) { + pub const Linux = 4000; + + syscall = Linux + 0, + exit = Linux + 1, + fork = Linux + 2, + read = Linux + 3, + write = Linux + 4, + open = Linux + 5, + close = Linux + 6, + waitpid = Linux + 7, + creat = Linux + 8, + link = Linux + 9, + unlink = Linux + 10, + execve = Linux + 11, + chdir = Linux + 12, + time = Linux + 13, + mknod = Linux + 14, + chmod = Linux + 15, + lchown = Linux + 16, + @"break" = Linux + 17, + unused18 = Linux + 18, + lseek = Linux + 19, + getpid = Linux + 20, + mount = Linux + 21, + umount = Linux + 22, + setuid = Linux + 23, + getuid = Linux + 24, + stime = Linux + 25, + ptrace = Linux + 26, + alarm = Linux + 27, + unused28 = Linux + 28, + pause = Linux + 29, + utime = Linux + 30, + stty = Linux + 31, + gtty = Linux + 32, + access = Linux + 33, + nice = Linux + 34, + ftime = Linux + 35, + sync = Linux + 36, + kill = Linux + 37, + rename = Linux + 38, + mkdir = Linux + 39, + rmdir = Linux + 40, + dup = Linux + 41, + pipe = Linux + 42, + times = Linux + 43, + prof = Linux + 44, + brk = Linux + 45, + setgid = Linux + 46, + getgid = Linux + 47, + signal = Linux + 48, + geteuid = Linux + 49, + getegid = Linux + 50, + acct = Linux + 51, + umount2 = Linux + 52, + lock = Linux + 53, + ioctl = Linux + 54, + fcntl = Linux + 55, + mpx = Linux + 56, + setpgid = Linux + 57, + ulimit = Linux + 58, + unused59 = Linux + 59, + umask = Linux + 60, + chroot = Linux + 61, + ustat = Linux + 62, + dup2 = Linux + 63, + getppid = Linux + 64, + getpgrp = Linux + 65, + setsid = Linux + 66, + sigaction = Linux + 67, + sgetmask = Linux + 68, + ssetmask = Linux + 69, + setreuid = Linux + 70, + setregid = Linux + 71, + sigsuspend = Linux + 72, + sigpending = Linux + 73, + sethostname = Linux + 74, + setrlimit = Linux + 75, + getrlimit = Linux + 76, + getrusage = Linux + 77, + gettimeofday = Linux + 78, + settimeofday = Linux + 79, + getgroups = Linux + 80, + setgroups = Linux + 81, + reserved82 = Linux + 82, + symlink = Linux + 83, + unused84 = Linux + 84, + readlink = Linux + 85, + uselib = Linux + 86, + swapon = Linux + 87, + reboot = Linux + 88, + readdir = Linux + 89, + mmap = Linux + 90, + munmap = Linux + 91, + truncate = Linux + 92, + ftruncate = Linux + 93, + fchmod = Linux + 94, + fchown = Linux + 95, + getpriority = Linux + 96, + setpriority = Linux + 97, + profil = Linux + 98, + statfs = Linux + 99, + fstatfs = Linux + 100, + ioperm = Linux + 101, + socketcall = Linux + 102, + syslog = Linux + 103, + setitimer = Linux + 104, + getitimer = Linux + 105, + stat = Linux + 106, + lstat = Linux + 107, + fstat = Linux + 108, + unused109 = Linux + 109, + iopl = Linux + 110, + vhangup = Linux + 111, + idle = Linux + 112, + vm86 = Linux + 113, + wait4 = Linux + 114, + swapoff = Linux + 115, + sysinfo = Linux + 116, + ipc = Linux + 117, + fsync = Linux + 118, + sigreturn = Linux + 119, + clone = Linux + 120, + setdomainname = Linux + 121, + uname = Linux + 122, + modify_ldt = Linux + 123, + adjtimex = Linux + 124, + mprotect = Linux + 125, + sigprocmask = Linux + 126, + create_module = Linux + 127, + init_module = Linux + 128, + delete_module = Linux + 129, + get_kernel_syms = Linux + 130, + quotactl = Linux + 131, + getpgid = Linux + 132, + fchdir = Linux + 133, + bdflush = Linux + 134, + sysfs = Linux + 135, + personality = Linux + 136, + afs_syscall = Linux + 137, + setfsuid = Linux + 138, + setfsgid = Linux + 139, + _llseek = Linux + 140, + getdents = Linux + 141, + _newselect = Linux + 142, + flock = Linux + 143, + msync = Linux + 144, + readv = Linux + 145, + writev = Linux + 146, + cacheflush = Linux + 147, + cachectl = Linux + 148, + sysmips = Linux + 149, + unused150 = Linux + 150, + getsid = Linux + 151, + fdatasync = Linux + 152, + _sysctl = Linux + 153, + mlock = Linux + 154, + munlock = Linux + 155, + mlockall = Linux + 156, + munlockall = Linux + 157, + sched_setparam = Linux + 158, + sched_getparam = Linux + 159, + sched_setscheduler = Linux + 160, + sched_getscheduler = Linux + 161, + sched_yield = Linux + 162, + sched_get_priority_max = Linux + 163, + sched_get_priority_min = Linux + 164, + sched_rr_get_interval = Linux + 165, + nanosleep = Linux + 166, + mremap = Linux + 167, + accept = Linux + 168, + bind = Linux + 169, + connect = Linux + 170, + getpeername = Linux + 171, + getsockname = Linux + 172, + getsockopt = Linux + 173, + listen = Linux + 174, + recv = Linux + 175, + recvfrom = Linux + 176, + recvmsg = Linux + 177, + send = Linux + 178, + sendmsg = Linux + 179, + sendto = Linux + 180, + setsockopt = Linux + 181, + shutdown = Linux + 182, + socket = Linux + 183, + socketpair = Linux + 184, + setresuid = Linux + 185, + getresuid = Linux + 186, + query_module = Linux + 187, + poll = Linux + 188, + nfsservctl = Linux + 189, + setresgid = Linux + 190, + getresgid = Linux + 191, + prctl = Linux + 192, + rt_sigreturn = Linux + 193, + rt_sigaction = Linux + 194, + rt_sigprocmask = Linux + 195, + rt_sigpending = Linux + 196, + rt_sigtimedwait = Linux + 197, + rt_sigqueueinfo = Linux + 198, + rt_sigsuspend = Linux + 199, + pread64 = Linux + 200, + pwrite64 = Linux + 201, + chown = Linux + 202, + getcwd = Linux + 203, + capget = Linux + 204, + capset = Linux + 205, + sigaltstack = Linux + 206, + sendfile = Linux + 207, + getpmsg = Linux + 208, + putpmsg = Linux + 209, + mmap2 = Linux + 210, + truncate64 = Linux + 211, + ftruncate64 = Linux + 212, + stat64 = Linux + 213, + lstat64 = Linux + 214, + fstat64 = Linux + 215, + pivot_root = Linux + 216, + mincore = Linux + 217, + madvise = Linux + 218, + getdents64 = Linux + 219, + fcntl64 = Linux + 220, + reserved221 = Linux + 221, + gettid = Linux + 222, + readahead = Linux + 223, + setxattr = Linux + 224, + lsetxattr = Linux + 225, + fsetxattr = Linux + 226, + getxattr = Linux + 227, + lgetxattr = Linux + 228, + fgetxattr = Linux + 229, + listxattr = Linux + 230, + llistxattr = Linux + 231, + flistxattr = Linux + 232, + removexattr = Linux + 233, + lremovexattr = Linux + 234, + fremovexattr = Linux + 235, + tkill = Linux + 236, + sendfile64 = Linux + 237, + futex = Linux + 238, + sched_setaffinity = Linux + 239, + sched_getaffinity = Linux + 240, + io_setup = Linux + 241, + io_destroy = Linux + 242, + io_getevents = Linux + 243, + io_submit = Linux + 244, + io_cancel = Linux + 245, + exit_group = Linux + 246, + lookup_dcookie = Linux + 247, + epoll_create = Linux + 248, + epoll_ctl = Linux + 249, + epoll_wait = Linux + 250, + remap_file_pages = Linux + 251, + set_tid_address = Linux + 252, + restart_syscall = Linux + 253, + fadvise64 = Linux + 254, + statfs64 = Linux + 255, + fstatfs64 = Linux + 256, + timer_create = Linux + 257, + timer_settime = Linux + 258, + timer_gettime = Linux + 259, + timer_getoverrun = Linux + 260, + timer_delete = Linux + 261, + clock_settime = Linux + 262, + clock_gettime = Linux + 263, + clock_getres = Linux + 264, + clock_nanosleep = Linux + 265, + tgkill = Linux + 266, + utimes = Linux + 267, + mbind = Linux + 268, + get_mempolicy = Linux + 269, + set_mempolicy = Linux + 270, + mq_open = Linux + 271, + mq_unlink = Linux + 272, + mq_timedsend = Linux + 273, + mq_timedreceive = Linux + 274, + mq_notify = Linux + 275, + mq_getsetattr = Linux + 276, + vserver = Linux + 277, + waitid = Linux + 278, + add_key = Linux + 280, + request_key = Linux + 281, + keyctl = Linux + 282, + set_thread_area = Linux + 283, + inotify_init = Linux + 284, + inotify_add_watch = Linux + 285, + inotify_rm_watch = Linux + 286, + migrate_pages = Linux + 287, + openat = Linux + 288, + mkdirat = Linux + 289, + mknodat = Linux + 290, + fchownat = Linux + 291, + futimesat = Linux + 292, + fstatat64 = Linux + 293, + unlinkat = Linux + 294, + renameat = Linux + 295, + linkat = Linux + 296, + symlinkat = Linux + 297, + readlinkat = Linux + 298, + fchmodat = Linux + 299, + faccessat = Linux + 300, + pselect6 = Linux + 301, + ppoll = Linux + 302, + unshare = Linux + 303, + splice = Linux + 304, + sync_file_range = Linux + 305, + tee = Linux + 306, + vmsplice = Linux + 307, + move_pages = Linux + 308, + set_robust_list = Linux + 309, + get_robust_list = Linux + 310, + kexec_load = Linux + 311, + getcpu = Linux + 312, + epoll_pwait = Linux + 313, + ioprio_set = Linux + 314, + ioprio_get = Linux + 315, + utimensat = Linux + 316, + signalfd = Linux + 317, + timerfd = Linux + 318, + eventfd = Linux + 319, + fallocate = Linux + 320, + timerfd_create = Linux + 321, + timerfd_gettime = Linux + 322, + timerfd_settime = Linux + 323, + signalfd4 = Linux + 324, + eventfd2 = Linux + 325, + epoll_create1 = Linux + 326, + dup3 = Linux + 327, + pipe2 = Linux + 328, + inotify_init1 = Linux + 329, + preadv = Linux + 330, + pwritev = Linux + 331, + rt_tgsigqueueinfo = Linux + 332, + perf_event_open = Linux + 333, + accept4 = Linux + 334, + recvmmsg = Linux + 335, + fanotify_init = Linux + 336, + fanotify_mark = Linux + 337, + prlimit64 = Linux + 338, + name_to_handle_at = Linux + 339, + open_by_handle_at = Linux + 340, + clock_adjtime = Linux + 341, + syncfs = Linux + 342, + sendmmsg = Linux + 343, + setns = Linux + 344, + process_vm_readv = Linux + 345, + process_vm_writev = Linux + 346, + kcmp = Linux + 347, + finit_module = Linux + 348, + sched_setattr = Linux + 349, + sched_getattr = Linux + 350, + renameat2 = Linux + 351, + seccomp = Linux + 352, + getrandom = Linux + 353, + memfd_create = Linux + 354, + bpf = Linux + 355, + execveat = Linux + 356, + userfaultfd = Linux + 357, + membarrier = Linux + 358, + mlock2 = Linux + 359, + copy_file_range = Linux + 360, + preadv2 = Linux + 361, + pwritev2 = Linux + 362, + pkey_mprotect = Linux + 363, + pkey_alloc = Linux + 364, + pkey_free = Linux + 365, + statx = Linux + 366, + rseq = Linux + 367, + io_pgetevents = Linux + 368, + openat2 = Linux + 437, + pidfd_getfd = Linux + 438, + + _, +}; + +pub const O_CREAT = 0o0400; +pub const O_EXCL = 0o02000; +pub const O_NOCTTY = 0o04000; +pub const O_TRUNC = 0o01000; +pub const O_APPEND = 0o0010; +pub const O_NONBLOCK = 0o0200; +pub const O_DSYNC = 0o0020; +pub const O_SYNC = 0o040020; +pub const O_RSYNC = 0o040020; +pub const O_DIRECTORY = 0o0200000; +pub const O_NOFOLLOW = 0o0400000; +pub const O_CLOEXEC = 0o02000000; + +pub const O_ASYNC = 0o010000; +pub const O_DIRECT = 0o0100000; +pub const O_LARGEFILE = 0o020000; +pub const O_NOATIME = 0o01000000; +pub const O_PATH = 0o010000000; +pub const O_TMPFILE = 0o020200000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 24; +pub const F_GETOWN = 23; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_GETLK = 33; +pub const F_SETLK = 34; +pub const F_SETLKW = 35; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +pub const MMAP2_UNIT = 4096; + +pub const MAP_NORESERVE = 0x0400; +pub const MAP_GROWSDOWN = 0x1000; +pub const MAP_DENYWRITE = 0x2000; +pub const MAP_EXECUTABLE = 0x4000; +pub const MAP_LOCKED = 0x8000; +pub const MAP_32BIT = 0x40; + +pub const SO_DEBUG = 1; +pub const SO_REUSEADDR = 0x0004; +pub const SO_KEEPALIVE = 0x0008; +pub const SO_DONTROUTE = 0x0010; +pub const SO_BROADCAST = 0x0020; +pub const SO_LINGER = 0x0080; +pub const SO_OOBINLINE = 0x0100; +pub const SO_REUSEPORT = 0x0200; +pub const SO_SNDBUF = 0x1001; +pub const SO_RCVBUF = 0x1002; +pub const SO_SNDLOWAT = 0x1003; +pub const SO_RCVLOWAT = 0x1004; +pub const SO_RCVTIMEO = 0x1006; +pub const SO_SNDTIMEO = 0x1005; +pub const SO_ERROR = 0x1007; +pub const SO_TYPE = 0x1008; +pub const SO_ACCEPTCONN = 0x1009; +pub const SO_PROTOCOL = 0x1028; +pub const SO_DOMAIN = 0x1029; +pub const SO_NO_CHECK = 11; +pub const SO_PRIORITY = 12; +pub const SO_BSDCOMPAT = 14; +pub const SO_PASSCRED = 17; +pub const SO_PEERCRED = 18; +pub const SO_PEERSEC = 30; +pub const SO_SNDBUFFORCE = 31; +pub const SO_RCVBUFFORCE = 33; + +pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; +pub const VDSO_CGT_VER = "LINUX_2.6.39"; + +pub const Flock = extern struct { + l_type: i16, + l_whence: i16, + __pad0: [4]u8, + l_start: off_t, + l_len: off_t, + l_pid: pid_t, + __unused: [4]u8, +}; + +pub const blksize_t = i32; +pub const nlink_t = u32; +pub const time_t = isize; +pub const mode_t = u32; +pub const off_t = i64; +pub const ino_t = u64; +pub const dev_t = usize; +pub const blkcnt_t = i64; + +pub const Stat = extern struct { + dev: u32, + __pad0: [3]u32, + ino: ino_t, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: dev_t, + __pad1: [3]u32, + size: off_t, + atim: timespec, + mtim: timespec, + ctim: timespec, + blksize: blksize_t, + __pad3: [1]u32, + blocks: blkcnt_t, + __pad4: [14]usize, + + pub fn atime(self: Stat) timespec { + return self.atim; + } + + pub fn mtime(self: Stat) timespec { + return self.mtim; + } + + pub fn ctime(self: Stat) timespec { + return self.ctim; + } +}; + +pub const timespec = extern struct { + tv_sec: isize, + tv_nsec: isize, +}; + +pub const timeval = extern struct { + tv_sec: isize, + tv_usec: isize, +}; + +pub const timezone = extern struct { + tz_minuteswest: i32, + tz_dsttime: i32, +}; + +pub const Elf_Symndx = u32; diff --git a/lib/std/os/bits/linux/mipsel.zig b/lib/std/os/bits/linux/mipsel.zig deleted file mode 100644 index 5946e821ad9fdb4748b50178bc49486643eab1aa..0000000000000000000000000000000000000000 --- a/lib/std/os/bits/linux/mipsel.zig +++ /dev/null @@ -1,543 +0,0 @@ -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; - -pub const SYS = extern enum(usize) { - pub const Linux = 4000; - - syscall = Linux + 0, - exit = Linux + 1, - fork = Linux + 2, - read = Linux + 3, - write = Linux + 4, - open = Linux + 5, - close = Linux + 6, - waitpid = Linux + 7, - creat = Linux + 8, - link = Linux + 9, - unlink = Linux + 10, - execve = Linux + 11, - chdir = Linux + 12, - time = Linux + 13, - mknod = Linux + 14, - chmod = Linux + 15, - lchown = Linux + 16, - @"break" = Linux + 17, - unused18 = Linux + 18, - lseek = Linux + 19, - getpid = Linux + 20, - mount = Linux + 21, - umount = Linux + 22, - setuid = Linux + 23, - getuid = Linux + 24, - stime = Linux + 25, - ptrace = Linux + 26, - alarm = Linux + 27, - unused28 = Linux + 28, - pause = Linux + 29, - utime = Linux + 30, - stty = Linux + 31, - gtty = Linux + 32, - access = Linux + 33, - nice = Linux + 34, - ftime = Linux + 35, - sync = Linux + 36, - kill = Linux + 37, - rename = Linux + 38, - mkdir = Linux + 39, - rmdir = Linux + 40, - dup = Linux + 41, - pipe = Linux + 42, - times = Linux + 43, - prof = Linux + 44, - brk = Linux + 45, - setgid = Linux + 46, - getgid = Linux + 47, - signal = Linux + 48, - geteuid = Linux + 49, - getegid = Linux + 50, - acct = Linux + 51, - umount2 = Linux + 52, - lock = Linux + 53, - ioctl = Linux + 54, - fcntl = Linux + 55, - mpx = Linux + 56, - setpgid = Linux + 57, - ulimit = Linux + 58, - unused59 = Linux + 59, - umask = Linux + 60, - chroot = Linux + 61, - ustat = Linux + 62, - dup2 = Linux + 63, - getppid = Linux + 64, - getpgrp = Linux + 65, - setsid = Linux + 66, - sigaction = Linux + 67, - sgetmask = Linux + 68, - ssetmask = Linux + 69, - setreuid = Linux + 70, - setregid = Linux + 71, - sigsuspend = Linux + 72, - sigpending = Linux + 73, - sethostname = Linux + 74, - setrlimit = Linux + 75, - getrlimit = Linux + 76, - getrusage = Linux + 77, - gettimeofday = Linux + 78, - settimeofday = Linux + 79, - getgroups = Linux + 80, - setgroups = Linux + 81, - reserved82 = Linux + 82, - symlink = Linux + 83, - unused84 = Linux + 84, - readlink = Linux + 85, - uselib = Linux + 86, - swapon = Linux + 87, - reboot = Linux + 88, - readdir = Linux + 89, - mmap = Linux + 90, - munmap = Linux + 91, - truncate = Linux + 92, - ftruncate = Linux + 93, - fchmod = Linux + 94, - fchown = Linux + 95, - getpriority = Linux + 96, - setpriority = Linux + 97, - profil = Linux + 98, - statfs = Linux + 99, - fstatfs = Linux + 100, - ioperm = Linux + 101, - socketcall = Linux + 102, - syslog = Linux + 103, - setitimer = Linux + 104, - getitimer = Linux + 105, - stat = Linux + 106, - lstat = Linux + 107, - fstat = Linux + 108, - unused109 = Linux + 109, - iopl = Linux + 110, - vhangup = Linux + 111, - idle = Linux + 112, - vm86 = Linux + 113, - wait4 = Linux + 114, - swapoff = Linux + 115, - sysinfo = Linux + 116, - ipc = Linux + 117, - fsync = Linux + 118, - sigreturn = Linux + 119, - clone = Linux + 120, - setdomainname = Linux + 121, - uname = Linux + 122, - modify_ldt = Linux + 123, - adjtimex = Linux + 124, - mprotect = Linux + 125, - sigprocmask = Linux + 126, - create_module = Linux + 127, - init_module = Linux + 128, - delete_module = Linux + 129, - get_kernel_syms = Linux + 130, - quotactl = Linux + 131, - getpgid = Linux + 132, - fchdir = Linux + 133, - bdflush = Linux + 134, - sysfs = Linux + 135, - personality = Linux + 136, - afs_syscall = Linux + 137, - setfsuid = Linux + 138, - setfsgid = Linux + 139, - _llseek = Linux + 140, - getdents = Linux + 141, - _newselect = Linux + 142, - flock = Linux + 143, - msync = Linux + 144, - readv = Linux + 145, - writev = Linux + 146, - cacheflush = Linux + 147, - cachectl = Linux + 148, - sysmips = Linux + 149, - unused150 = Linux + 150, - getsid = Linux + 151, - fdatasync = Linux + 152, - _sysctl = Linux + 153, - mlock = Linux + 154, - munlock = Linux + 155, - mlockall = Linux + 156, - munlockall = Linux + 157, - sched_setparam = Linux + 158, - sched_getparam = Linux + 159, - sched_setscheduler = Linux + 160, - sched_getscheduler = Linux + 161, - sched_yield = Linux + 162, - sched_get_priority_max = Linux + 163, - sched_get_priority_min = Linux + 164, - sched_rr_get_interval = Linux + 165, - nanosleep = Linux + 166, - mremap = Linux + 167, - accept = Linux + 168, - bind = Linux + 169, - connect = Linux + 170, - getpeername = Linux + 171, - getsockname = Linux + 172, - getsockopt = Linux + 173, - listen = Linux + 174, - recv = Linux + 175, - recvfrom = Linux + 176, - recvmsg = Linux + 177, - send = Linux + 178, - sendmsg = Linux + 179, - sendto = Linux + 180, - setsockopt = Linux + 181, - shutdown = Linux + 182, - socket = Linux + 183, - socketpair = Linux + 184, - setresuid = Linux + 185, - getresuid = Linux + 186, - query_module = Linux + 187, - poll = Linux + 188, - nfsservctl = Linux + 189, - setresgid = Linux + 190, - getresgid = Linux + 191, - prctl = Linux + 192, - rt_sigreturn = Linux + 193, - rt_sigaction = Linux + 194, - rt_sigprocmask = Linux + 195, - rt_sigpending = Linux + 196, - rt_sigtimedwait = Linux + 197, - rt_sigqueueinfo = Linux + 198, - rt_sigsuspend = Linux + 199, - pread64 = Linux + 200, - pwrite64 = Linux + 201, - chown = Linux + 202, - getcwd = Linux + 203, - capget = Linux + 204, - capset = Linux + 205, - sigaltstack = Linux + 206, - sendfile = Linux + 207, - getpmsg = Linux + 208, - putpmsg = Linux + 209, - mmap2 = Linux + 210, - truncate64 = Linux + 211, - ftruncate64 = Linux + 212, - stat64 = Linux + 213, - lstat64 = Linux + 214, - fstat64 = Linux + 215, - pivot_root = Linux + 216, - mincore = Linux + 217, - madvise = Linux + 218, - getdents64 = Linux + 219, - fcntl64 = Linux + 220, - reserved221 = Linux + 221, - gettid = Linux + 222, - readahead = Linux + 223, - setxattr = Linux + 224, - lsetxattr = Linux + 225, - fsetxattr = Linux + 226, - getxattr = Linux + 227, - lgetxattr = Linux + 228, - fgetxattr = Linux + 229, - listxattr = Linux + 230, - llistxattr = Linux + 231, - flistxattr = Linux + 232, - removexattr = Linux + 233, - lremovexattr = Linux + 234, - fremovexattr = Linux + 235, - tkill = Linux + 236, - sendfile64 = Linux + 237, - futex = Linux + 238, - sched_setaffinity = Linux + 239, - sched_getaffinity = Linux + 240, - io_setup = Linux + 241, - io_destroy = Linux + 242, - io_getevents = Linux + 243, - io_submit = Linux + 244, - io_cancel = Linux + 245, - exit_group = Linux + 246, - lookup_dcookie = Linux + 247, - epoll_create = Linux + 248, - epoll_ctl = Linux + 249, - epoll_wait = Linux + 250, - remap_file_pages = Linux + 251, - set_tid_address = Linux + 252, - restart_syscall = Linux + 253, - fadvise64 = Linux + 254, - statfs64 = Linux + 255, - fstatfs64 = Linux + 256, - timer_create = Linux + 257, - timer_settime = Linux + 258, - timer_gettime = Linux + 259, - timer_getoverrun = Linux + 260, - timer_delete = Linux + 261, - clock_settime = Linux + 262, - clock_gettime = Linux + 263, - clock_getres = Linux + 264, - clock_nanosleep = Linux + 265, - tgkill = Linux + 266, - utimes = Linux + 267, - mbind = Linux + 268, - get_mempolicy = Linux + 269, - set_mempolicy = Linux + 270, - mq_open = Linux + 271, - mq_unlink = Linux + 272, - mq_timedsend = Linux + 273, - mq_timedreceive = Linux + 274, - mq_notify = Linux + 275, - mq_getsetattr = Linux + 276, - vserver = Linux + 277, - waitid = Linux + 278, - add_key = Linux + 280, - request_key = Linux + 281, - keyctl = Linux + 282, - set_thread_area = Linux + 283, - inotify_init = Linux + 284, - inotify_add_watch = Linux + 285, - inotify_rm_watch = Linux + 286, - migrate_pages = Linux + 287, - openat = Linux + 288, - mkdirat = Linux + 289, - mknodat = Linux + 290, - fchownat = Linux + 291, - futimesat = Linux + 292, - fstatat64 = Linux + 293, - unlinkat = Linux + 294, - renameat = Linux + 295, - linkat = Linux + 296, - symlinkat = Linux + 297, - readlinkat = Linux + 298, - fchmodat = Linux + 299, - faccessat = Linux + 300, - pselect6 = Linux + 301, - ppoll = Linux + 302, - unshare = Linux + 303, - splice = Linux + 304, - sync_file_range = Linux + 305, - tee = Linux + 306, - vmsplice = Linux + 307, - move_pages = Linux + 308, - set_robust_list = Linux + 309, - get_robust_list = Linux + 310, - kexec_load = Linux + 311, - getcpu = Linux + 312, - epoll_pwait = Linux + 313, - ioprio_set = Linux + 314, - ioprio_get = Linux + 315, - utimensat = Linux + 316, - signalfd = Linux + 317, - timerfd = Linux + 318, - eventfd = Linux + 319, - fallocate = Linux + 320, - timerfd_create = Linux + 321, - timerfd_gettime = Linux + 322, - timerfd_settime = Linux + 323, - signalfd4 = Linux + 324, - eventfd2 = Linux + 325, - epoll_create1 = Linux + 326, - dup3 = Linux + 327, - pipe2 = Linux + 328, - inotify_init1 = Linux + 329, - preadv = Linux + 330, - pwritev = Linux + 331, - rt_tgsigqueueinfo = Linux + 332, - perf_event_open = Linux + 333, - accept4 = Linux + 334, - recvmmsg = Linux + 335, - fanotify_init = Linux + 336, - fanotify_mark = Linux + 337, - prlimit64 = Linux + 338, - name_to_handle_at = Linux + 339, - open_by_handle_at = Linux + 340, - clock_adjtime = Linux + 341, - syncfs = Linux + 342, - sendmmsg = Linux + 343, - setns = Linux + 344, - process_vm_readv = Linux + 345, - process_vm_writev = Linux + 346, - kcmp = Linux + 347, - finit_module = Linux + 348, - sched_setattr = Linux + 349, - sched_getattr = Linux + 350, - renameat2 = Linux + 351, - seccomp = Linux + 352, - getrandom = Linux + 353, - memfd_create = Linux + 354, - bpf = Linux + 355, - execveat = Linux + 356, - userfaultfd = Linux + 357, - membarrier = Linux + 358, - mlock2 = Linux + 359, - copy_file_range = Linux + 360, - preadv2 = Linux + 361, - pwritev2 = Linux + 362, - pkey_mprotect = Linux + 363, - pkey_alloc = Linux + 364, - pkey_free = Linux + 365, - statx = Linux + 366, - rseq = Linux + 367, - io_pgetevents = Linux + 368, - openat2 = Linux + 437, - pidfd_getfd = Linux + 438, - - _, -}; - -pub const O_CREAT = 0o0400; -pub const O_EXCL = 0o02000; -pub const O_NOCTTY = 0o04000; -pub const O_TRUNC = 0o01000; -pub const O_APPEND = 0o0010; -pub const O_NONBLOCK = 0o0200; -pub const O_DSYNC = 0o0020; -pub const O_SYNC = 0o040020; -pub const O_RSYNC = 0o040020; -pub const O_DIRECTORY = 0o0200000; -pub const O_NOFOLLOW = 0o0400000; -pub const O_CLOEXEC = 0o02000000; - -pub const O_ASYNC = 0o010000; -pub const O_DIRECT = 0o0100000; -pub const O_LARGEFILE = 0o020000; -pub const O_NOATIME = 0o01000000; -pub const O_PATH = 0o010000000; -pub const O_TMPFILE = 0o020200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 24; -pub const F_GETOWN = 23; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 33; -pub const F_SETLK = 34; -pub const F_SETLKW = 35; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const MMAP2_UNIT = 4096; - -pub const MAP_NORESERVE = 0x0400; -pub const MAP_GROWSDOWN = 0x1000; -pub const MAP_DENYWRITE = 0x2000; -pub const MAP_EXECUTABLE = 0x4000; -pub const MAP_LOCKED = 0x8000; -pub const MAP_32BIT = 0x40; - -pub const SO_DEBUG = 1; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_LINGER = 0x0080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_ACCEPTCONN = 0x1009; -pub const SO_PROTOCOL = 0x1028; -pub const SO_DOMAIN = 0x1029; -pub const SO_NO_CHECK = 11; -pub const SO_PRIORITY = 12; -pub const SO_BSDCOMPAT = 14; -pub const SO_PASSCRED = 17; -pub const SO_PEERCRED = 18; -pub const SO_PEERSEC = 30; -pub const SO_SNDBUFFORCE = 31; -pub const SO_RCVBUFFORCE = 33; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6.39"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - __pad0: [4]u8, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - __unused: [4]u8, -}; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = isize; -pub const mode_t = u32; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = usize; -pub const blkcnt_t = i64; - -pub const Stat = extern struct { - dev: u32, - __pad0: [3]u32, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad1: [3]u32, - size: off_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - blksize: blksize_t, - __pad3: [1]u32, - blocks: blkcnt_t, - __pad4: [14]usize, - - pub fn atime(self: Stat) timespec { - return self.atim; - } - - pub fn mtime(self: Stat) timespec { - return self.mtim; - } - - pub fn ctime(self: Stat) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const Elf_Symndx = u32; diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 87ee19898532080613f6f30cebfb6b710541faff..5631a90ef95482d5c70d31d01c61eb92cae3ef20 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -19,7 +19,7 @@ pub usingnamespace switch (builtin.arch) { .aarch64 => @import("linux/arm64.zig"), .arm => @import("linux/arm-eabi.zig"), .riscv64 => @import("linux/riscv64.zig"), - .mipsel => @import("linux/mipsel.zig"), + .mips, .mipsel => @import("linux/mips.zig"), else => struct {}, }; pub usingnamespace @import("bits.zig"); diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig new file mode 100644 index 0000000000000000000000000000000000000000..87c55db9f6d8280ac54cf8315bb509f6e1cf3db4 --- /dev/null +++ b/lib/std/os/linux/mips.zig @@ -0,0 +1,161 @@ +usingnamespace @import("../bits.zig"); + +pub fn syscall0(number: SYS) usize { + return asm volatile ( + \\ syscall + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)) + : "memory", "cc", "$7" + ); +} + +pub fn syscall_pipe(fd: *[2]i32) usize { + return asm volatile ( + \\ .set noat + \\ .set noreorder + \\ syscall + \\ blez $7, 1f + \\ nop + \\ b 2f + \\ subu $2, $0, $2 + \\ 1: + \\ sw $2, 0($4) + \\ sw $3, 4($4) + \\ 2: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(SYS.pipe)) + : "memory", "cc", "$7" + ); +} + +pub fn syscall1(number: SYS, arg1: usize) usize { + return asm volatile ( + \\ syscall + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)), + [arg1] "{$4}" (arg1) + : "memory", "cc", "$7" + ); +} + +pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { + return asm volatile ( + \\ syscall + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)), + [arg1] "{$4}" (arg1), + [arg2] "{$5}" (arg2) + : "memory", "cc", "$7" + ); +} + +pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { + return asm volatile ( + \\ syscall + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)), + [arg1] "{$4}" (arg1), + [arg2] "{$5}" (arg2), + [arg3] "{$6}" (arg3) + : "memory", "cc", "$7" + ); +} + +pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { + return asm volatile ( + \\ syscall + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)), + [arg1] "{$4}" (arg1), + [arg2] "{$5}" (arg2), + [arg3] "{$6}" (arg3), + [arg4] "{$7}" (arg4) + : "memory", "cc", "$7" + ); +} + +pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { + return asm volatile ( + \\ .set noat + \\ subu $sp, $sp, 24 + \\ sw %[arg5], 16($sp) + \\ syscall + \\ addu $sp, $sp, 24 + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)), + [arg1] "{$4}" (arg1), + [arg2] "{$5}" (arg2), + [arg3] "{$6}" (arg3), + [arg4] "{$7}" (arg4), + [arg5] "r" (arg5) + : "memory", "cc", "$7" + ); +} + +pub fn syscall6( + number: SYS, + arg1: usize, + arg2: usize, + arg3: usize, + arg4: usize, + arg5: usize, + arg6: usize, +) usize { + return asm volatile ( + \\ .set noat + \\ subu $sp, $sp, 24 + \\ sw %[arg5], 16($sp) + \\ sw %[arg6], 20($sp) + \\ syscall + \\ addu $sp, $sp, 24 + \\ blez $7, 1f + \\ subu $2, $0, $2 + \\ 1: + : [ret] "={$2}" (-> usize) + : [number] "{$2}" (@enumToInt(number)), + [arg1] "{$4}" (arg1), + [arg2] "{$5}" (arg2), + [arg3] "{$6}" (arg3), + [arg4] "{$7}" (arg4), + [arg5] "r" (arg5), + [arg6] "r" (arg6) + : "memory", "cc", "$7" + ); +} + +/// This matches the libc clone function. +pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; + +pub fn restore() callconv(.Naked) void { + return asm volatile ("syscall" + : + : [number] "{$2}" (@enumToInt(SYS.sigreturn)) + : "memory", "cc", "$7" + ); +} + +pub fn restore_rt() callconv(.Naked) void { + return asm volatile ("syscall" + : + : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)) + : "memory", "cc", "$7" + ); +} diff --git a/lib/std/os/linux/mipsel.zig b/lib/std/os/linux/mipsel.zig deleted file mode 100644 index 87c55db9f6d8280ac54cf8315bb509f6e1cf3db4..0000000000000000000000000000000000000000 --- a/lib/std/os/linux/mipsel.zig +++ /dev/null @@ -1,161 +0,0 @@ -usingnamespace @import("../bits.zig"); - -pub fn syscall0(number: SYS) usize { - return asm volatile ( - \\ syscall - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)) - : "memory", "cc", "$7" - ); -} - -pub fn syscall_pipe(fd: *[2]i32) usize { - return asm volatile ( - \\ .set noat - \\ .set noreorder - \\ syscall - \\ blez $7, 1f - \\ nop - \\ b 2f - \\ subu $2, $0, $2 - \\ 1: - \\ sw $2, 0($4) - \\ sw $3, 4($4) - \\ 2: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(SYS.pipe)) - : "memory", "cc", "$7" - ); -} - -pub fn syscall1(number: SYS, arg1: usize) usize { - return asm volatile ( - \\ syscall - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)), - [arg1] "{$4}" (arg1) - : "memory", "cc", "$7" - ); -} - -pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { - return asm volatile ( - \\ syscall - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)), - [arg1] "{$4}" (arg1), - [arg2] "{$5}" (arg2) - : "memory", "cc", "$7" - ); -} - -pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { - return asm volatile ( - \\ syscall - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)), - [arg1] "{$4}" (arg1), - [arg2] "{$5}" (arg2), - [arg3] "{$6}" (arg3) - : "memory", "cc", "$7" - ); -} - -pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { - return asm volatile ( - \\ syscall - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)), - [arg1] "{$4}" (arg1), - [arg2] "{$5}" (arg2), - [arg3] "{$6}" (arg3), - [arg4] "{$7}" (arg4) - : "memory", "cc", "$7" - ); -} - -pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { - return asm volatile ( - \\ .set noat - \\ subu $sp, $sp, 24 - \\ sw %[arg5], 16($sp) - \\ syscall - \\ addu $sp, $sp, 24 - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)), - [arg1] "{$4}" (arg1), - [arg2] "{$5}" (arg2), - [arg3] "{$6}" (arg3), - [arg4] "{$7}" (arg4), - [arg5] "r" (arg5) - : "memory", "cc", "$7" - ); -} - -pub fn syscall6( - number: SYS, - arg1: usize, - arg2: usize, - arg3: usize, - arg4: usize, - arg5: usize, - arg6: usize, -) usize { - return asm volatile ( - \\ .set noat - \\ subu $sp, $sp, 24 - \\ sw %[arg5], 16($sp) - \\ sw %[arg6], 20($sp) - \\ syscall - \\ addu $sp, $sp, 24 - \\ blez $7, 1f - \\ subu $2, $0, $2 - \\ 1: - : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(number)), - [arg1] "{$4}" (arg1), - [arg2] "{$5}" (arg2), - [arg3] "{$6}" (arg3), - [arg4] "{$7}" (arg4), - [arg5] "r" (arg5), - [arg6] "r" (arg6) - : "memory", "cc", "$7" - ); -} - -/// This matches the libc clone function. -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; - -pub fn restore() callconv(.Naked) void { - return asm volatile ("syscall" - : - : [number] "{$2}" (@enumToInt(SYS.sigreturn)) - : "memory", "cc", "$7" - ); -} - -pub fn restore_rt() callconv(.Naked) void { - return asm volatile ("syscall" - : - : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)) - : "memory", "cc", "$7" - ); -} diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index e7d836eff6ceb1b171fc547a9db7fe50968abfc9..8cba45d4b380b68fb4aaa284c2aae63e0762e83d 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -48,7 +48,7 @@ const TLSVariant = enum { }; const tls_variant = switch (builtin.arch) { - .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mipsel => TLSVariant.VariantI, + .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mips, .mipsel => TLSVariant.VariantI, .x86_64, .i386 => TLSVariant.VariantII, else => @compileError("undefined tls_variant for this architecture"), }; @@ -64,7 +64,7 @@ const tls_tcb_size = switch (builtin.arch) { // Controls if the TP points to the end of the TCB instead of its beginning const tls_tp_points_past_tcb = switch (builtin.arch) { - .riscv32, .riscv64, .mipsel, .powerpc64, .powerpc64le => true, + .riscv32, .riscv64, .mips, .mipsel, .powerpc64, .powerpc64le => true, else => false, }; @@ -72,12 +72,12 @@ const tls_tp_points_past_tcb = switch (builtin.arch) { // make the generated code more efficient const tls_tp_offset = switch (builtin.arch) { - .mipsel => 0x7000, + .mips, .mipsel => 0x7000, else => 0, }; const tls_dtv_offset = switch (builtin.arch) { - .mipsel => 0x8000, + .mips, .mipsel => 0x8000, .riscv32, .riscv64 => 0x800, else => 0, }; @@ -156,7 +156,7 @@ pub fn setThreadPointer(addr: usize) void { : [addr] "r" (addr) ); }, - .mipsel => { + .mips, .mipsel => { const rc = std.os.linux.syscall1(.set_thread_area, addr); assert(rc == 0); }, diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index e0c2636df1d1c5ba92a9efc2d0bd81bb6ff3c33f..8bfd5408585af7a46d477a3dacedb864b85483f6 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -354,7 +354,7 @@ fn clone() callconv(.Naked) void { \\ ecall ); }, - .mipsel => { + .mips, .mipsel => { asm volatile ( \\ # Save function pointer and argument pointer on new thread stack \\ and $5, $5, -8 diff --git a/lib/std/start.zig b/lib/std/start.zig index fbb8140666d5627b425f99fdaa692e7165364ba0..631bb2e9f8703f95381f9cf5513525f9a05bd7ce 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -108,7 +108,7 @@ fn _start() callconv(.Naked) noreturn { : [argc] "=r" (-> [*]usize) ); }, - .mipsel => { + .mips, .mipsel => { // Need noat here because LLVM is free to pick any register starting_stack_ptr = asm ( \\ .set noat diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index 333287b3516db6394358200ae5afc9b45e02198b..df2e16a4bf73fcb67a09af0178d52a8f51d461c3 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -660,6 +660,9 @@ fn calcUtf16LeLen(utf8: []const u8) usize { } test "utf8ToUtf16LeStringLiteral" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + { const bytes = [_:0]u16{0x41}; const utf16 = utf8ToUtf16LeStringLiteral("A"); diff --git a/src/analyze.cpp b/src/analyze.cpp index 28b1f0cd76809b7fecbea0067d864e0f6f7e6c20..d1702738083c687c402034a562e995e7d2cf0c22 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1007,7 +1007,7 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) { { X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type); return abi_class == X64CABIClass_MEMORY || abi_class == X64CABIClass_MEMORY_nobyval; - } else if (g->zig_target->arch == ZigLLVM_mipsel) { + } else if (g->zig_target->arch == ZigLLVM_mips || g->zig_target->arch == ZigLLVM_mipsel) { return false; } zig_panic("TODO implement C ABI for this architecture. See https://github.com/ziglang/zig/issues/1481"); diff --git a/test/stage1/behavior/byteswap.zig b/test/stage1/behavior/byteswap.zig index d6e07e7a56887f2d5b6610338247bc238a5e460a..b980d6057db1e9731dd0321d2d8168793f01d426 100644 --- a/test/stage1/behavior/byteswap.zig +++ b/test/stage1/behavior/byteswap.zig @@ -43,7 +43,7 @@ test "@byteSwap vectors" { if (std.Target.current.os.tag == .dragonfly) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/3317 - if (std.Target.current.cpu.arch == .mipsel) return error.SkipZigTest; + if (std.Target.current.cpu.arch == .mipsel or std.Target.current.cpu.arch == .mips) return error.SkipZigTest; const ByteSwapVectorTest = struct { fn run() void { diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig index 83b21c5379e637c2f5137a00aac62b5304575224..d277590c7a1f686247837a8301c11906a0ba0633 100644 --- a/test/stage1/behavior/cast.zig +++ b/test/stage1/behavior/cast.zig @@ -16,6 +16,9 @@ test "integer literal to pointer cast" { } test "pointer reinterpret const float to int" { + // https://github.com/ziglang/zig/issues/3345 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + const float: f64 = 5.99999999999994648725e-01; const float_ptr = &float; const int_ptr = @ptrCast(*const i32, float_ptr); diff --git a/test/stage1/behavior/shuffle.zig b/test/stage1/behavior/shuffle.zig index 2189b3e0e1be17fef9bad84200fc95f50af09545..0069be56439b04a94cdc91477161ffa9f1ac03db 100644 --- a/test/stage1/behavior/shuffle.zig +++ b/test/stage1/behavior/shuffle.zig @@ -34,7 +34,7 @@ test "@shuffle" { // bool // Disabled because of #3317 - if (@import("builtin").arch != .mipsel) { + if (@import("builtin").arch != .mipsel and std.Target.current.cpu.arch != .mips) { var x2: @Vector(4, bool) = [4]bool{ false, true, false, true }; var v4: @Vector(2, bool) = [2]bool{ true, false }; const mask5: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 }; diff --git a/test/stage1/behavior/union.zig b/test/stage1/behavior/union.zig index be7a84c5b4502679a81766668db741fe1f5df59a..8555e712dd393d81942977763cf029183f322c31 100644 --- a/test/stage1/behavior/union.zig +++ b/test/stage1/behavior/union.zig @@ -623,6 +623,9 @@ test "0-sized extern union definition" { } test "union initializer generates padding only if needed" { + // https://github.com/ziglang/zig/issues/5127 + if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; + const U = union(enum) { A: u24, }; diff --git a/test/tests.zig b/test/tests.zig index a8c42c74959d0630559ad6f7763e9c374865a7d9..d5fdbd74cfc0213d536cb5b72291fb06f2419dd8 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -145,6 +145,31 @@ const test_targets = blk: { // .link_libc = true, //}, + TestTarget{ + .target = .{ + .cpu_arch = .mips, + .os_tag = .linux, + .abi = .none, + }, + }, + TestTarget{ + .target = .{ + .cpu_arch = .mips, + .os_tag = .linux, + .abi = .musl, + }, + .link_libc = true, + }, + // https://github.com/ziglang/zig/issues/4927 + //TestTarget{ + // .target = .{ + // .cpu_arch = .mips, + // .os_tag = .linux, + // .abi = .gnu, + // }, + // .link_libc = true, + //}, + TestTarget{ .target = .{ .cpu_arch = .mipsel,