authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-06 12:10:03-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-06 12:10:03-05:00
log697b1233f0c458b8ad8c374f6f7cce451142ca71
treedda25baa4519844d9541df34811ea82c78ce2733
parentb554f6294f4d1c36856b2749a6ff0e457cf0c1a6
signature Commit is signed but in an unrecognized format.

support other architectures for glibc startup files


272 files changed, 30049 insertions(+), 2454 deletions(-)

CMakeLists.txt+240-29
...@@ -1256,17 +1256,12 @@ set(ZIG_LIBC_FILES...@@ -1256,17 +1256,12 @@ set(ZIG_LIBC_FILES
1256 "glibc/bits/floatn-common.h"1256 "glibc/bits/floatn-common.h"
1257 "glibc/bits/libc-header-start.h"1257 "glibc/bits/libc-header-start.h"
1258 "glibc/bits/long-double.h"1258 "glibc/bits/long-double.h"
1259 "glibc/bits/param.h"
1260 "glibc/bits/pthreadtypes.h"1259 "glibc/bits/pthreadtypes.h"
1261 "glibc/bits/sched.h"
1262 "glibc/bits/select.h"1260 "glibc/bits/select.h"
1263 "glibc/bits/setjmp.h"
1264 "glibc/bits/signum-generic.h"1261 "glibc/bits/signum-generic.h"
1265 "glibc/bits/signum.h"
1266 "glibc/bits/stat.h"1262 "glibc/bits/stat.h"
1267 "glibc/bits/stdint-intn.h"1263 "glibc/bits/stdint-intn.h"
1268 "glibc/bits/stdlib-bsearch.h"1264 "glibc/bits/stdlib-bsearch.h"
1269 "glibc/bits/time.h"
1270 "glibc/bits/time64.h"1265 "glibc/bits/time64.h"
1271 "glibc/bits/timesize.h"1266 "glibc/bits/timesize.h"
1272 "glibc/bits/types/__sigset_t.h"1267 "glibc/bits/types/__sigset_t.h"
...@@ -1308,21 +1303,16 @@ set(ZIG_LIBC_FILES...@@ -1308,21 +1303,16 @@ set(ZIG_LIBC_FILES
1308 "glibc/include/libc-pointer-arith.h"1303 "glibc/include/libc-pointer-arith.h"
1309 "glibc/include/libc-symbols.h"1304 "glibc/include/libc-symbols.h"
1310 "glibc/include/pthread.h"1305 "glibc/include/pthread.h"
1311 "glibc/include/sched.h"
1312 "glibc/include/setjmp.h"
1313 "glibc/include/signal.h"1306 "glibc/include/signal.h"
1314 "glibc/include/stackinfo.h"
1315 "glibc/include/stap-probe.h"1307 "glibc/include/stap-probe.h"
1316 "glibc/include/stdc-predef.h"1308 "glibc/include/stdc-predef.h"
1317 "glibc/include/stdlib.h"1309 "glibc/include/stdlib.h"
1318 "glibc/include/sys/cdefs.h"1310 "glibc/include/sys/cdefs.h"
1319 "glibc/include/sys/param.h"
1320 "glibc/include/sys/select.h"1311 "glibc/include/sys/select.h"
1321 "glibc/include/sys/signal.h"1312 "glibc/include/sys/signal.h"
1322 "glibc/include/sys/stat.h"1313 "glibc/include/sys/stat.h"
1323 "glibc/include/sys/time.h"
1324 "glibc/include/sys/types.h"1314 "glibc/include/sys/types.h"
1325 "glibc/include/time.h"1315 "glibc/include/syscall.h"
1326 "glibc/io/bits/statx.h"1316 "glibc/io/bits/statx.h"
1327 "glibc/io/fstat.c"1317 "glibc/io/fstat.c"
1328 "glibc/io/fstat64.c"1318 "glibc/io/fstat64.c"
...@@ -1338,15 +1328,12 @@ set(ZIG_LIBC_FILES...@@ -1338,15 +1328,12 @@ set(ZIG_LIBC_FILES
1338 "glibc/locale/bits/types/__locale_t.h"1328 "glibc/locale/bits/types/__locale_t.h"
1339 "glibc/locale/bits/types/locale_t.h"1329 "glibc/locale/bits/types/locale_t.h"
1340 "glibc/misc/sys/cdefs.h"1330 "glibc/misc/sys/cdefs.h"
1341 "glibc/misc/sys/param.h"
1342 "glibc/misc/sys/select.h"1331 "glibc/misc/sys/select.h"
1332 "glibc/misc/syscall.h"
1343 "glibc/nptl/pthread_atfork.c"1333 "glibc/nptl/pthread_atfork.c"
1344 "glibc/posix/bits/cpu-set.h"1334 "glibc/posix/bits/cpu-set.h"
1345 "glibc/posix/bits/types.h"1335 "glibc/posix/bits/types.h"
1346 "glibc/posix/sched.h"
1347 "glibc/posix/sys/types.h"1336 "glibc/posix/sys/types.h"
1348 "glibc/setjmp/setjmp.h"
1349 "glibc/setjmp/setjmp.h"
1350 "glibc/signal/bits/types/sig_atomic_t.h"1337 "glibc/signal/bits/types/sig_atomic_t.h"
1351 "glibc/signal/bits/types/sigset_t.h"1338 "glibc/signal/bits/types/sigset_t.h"
1352 "glibc/signal/signal.h"1339 "glibc/signal/signal.h"
...@@ -1358,45 +1345,271 @@ set(ZIG_LIBC_FILES...@@ -1358,45 +1345,271 @@ set(ZIG_LIBC_FILES
1358 "glibc/stdlib/exit.h"1345 "glibc/stdlib/exit.h"
1359 "glibc/stdlib/stdlib.h"1346 "glibc/stdlib/stdlib.h"
1360 "glibc/string/endian.h"1347 "glibc/string/endian.h"
1361 "glibc/sysdeps/generic/allocalim.h"1348 "glibc/sysdeps/aarch64/bits/endian.h"
1349 "glibc/sysdeps/aarch64/crti.S"
1350 "glibc/sysdeps/aarch64/crtn.S"
1351 "glibc/sysdeps/aarch64/dl-sysdep.h"
1352 "glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h"
1353 "glibc/sysdeps/aarch64/start.S"
1354 "glibc/sysdeps/aarch64/sysdep.h"
1355 "glibc/sysdeps/alpha/bits/endian.h"
1356 "glibc/sysdeps/alpha/crti.S"
1357 "glibc/sysdeps/alpha/crtn.S"
1358 "glibc/sysdeps/alpha/dl-dtprocnum.h"
1359 "glibc/sysdeps/alpha/dl-sysdep.h"
1360 "glibc/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h"
1361 "glibc/sysdeps/alpha/start.S"
1362 "glibc/sysdeps/arm/bits/endian.h"
1363 "glibc/sysdeps/arm/crti.S"
1364 "glibc/sysdeps/arm/crtn.S"
1365 "glibc/sysdeps/arm/dl-sysdep.h"
1366 "glibc/sysdeps/arm/nptl/bits/pthreadtypes-arch.h"
1367 "glibc/sysdeps/arm/start.S"
1368 "glibc/sysdeps/arm/sysdep.h"
1369 "glibc/sysdeps/csky/abiv2/start.S"
1370 "glibc/sysdeps/csky/bits/endian.h"
1371 "glibc/sysdeps/csky/dl-sysdep.h"
1372 "glibc/sysdeps/csky/nptl/bits/pthreadtypes-arch.h"
1373 "glibc/sysdeps/csky/sysdep.h"
1362 "glibc/sysdeps/generic/dl-dtprocnum.h"1374 "glibc/sysdeps/generic/dl-dtprocnum.h"
1375 "glibc/sysdeps/generic/dl-sysdep.h"
1363 "glibc/sysdeps/generic/dwarf2.h"1376 "glibc/sysdeps/generic/dwarf2.h"
1364 "glibc/sysdeps/generic/libc-lock.h"1377 "glibc/sysdeps/generic/libc-lock.h"
1365 "glibc/sysdeps/generic/stackinfo.h"
1366 "glibc/sysdeps/generic/symbol-hacks.h"1378 "glibc/sysdeps/generic/symbol-hacks.h"
1379 "glibc/sysdeps/generic/sys/syscall.h"
1367 "glibc/sysdeps/generic/sysdep.h"1380 "glibc/sysdeps/generic/sysdep.h"
1381 "glibc/sysdeps/generic/tls.h"
1382 "glibc/sysdeps/hppa/bits/endian.h"
1383 "glibc/sysdeps/hppa/crti.S"
1384 "glibc/sysdeps/hppa/crtn.S"
1385 "glibc/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h"
1386 "glibc/sysdeps/hppa/start.S"
1387 "glibc/sysdeps/hppa/sysdep.h"
1388 "glibc/sysdeps/htl/bits/pthread.h"
1389 "glibc/sysdeps/htl/bits/thread-shared-types.h"
1390 "glibc/sysdeps/htl/libc-lockP.h"
1391 "glibc/sysdeps/htl/pthread.h"
1392 "glibc/sysdeps/i386/crti.S"
1393 "glibc/sysdeps/i386/crtn.S"
1394 "glibc/sysdeps/i386/htl/bits/pthreadtypes-arch.h"
1395 "glibc/sysdeps/i386/start.S"
1396 "glibc/sysdeps/i386/symbol-hacks.h"
1397 "glibc/sysdeps/i386/sysdep.h"
1398 "glibc/sysdeps/ia64/crti.S"
1399 "glibc/sysdeps/ia64/crtn.S"
1400 "glibc/sysdeps/ia64/dl-dtprocnum.h"
1401 "glibc/sysdeps/ia64/dl-sysdep.h"
1402 "glibc/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h"
1403 "glibc/sysdeps/ia64/start.S"
1404 "glibc/sysdeps/ia64/sysdep.h"
1405 "glibc/sysdeps/init_array/crti.S"
1406 "glibc/sysdeps/init_array/crtn.S"
1407 "glibc/sysdeps/m68k/bits/endian.h"
1408 "glibc/sysdeps/m68k/coldfire/sysdep.h"
1409 "glibc/sysdeps/m68k/crti.S"
1410 "glibc/sysdeps/m68k/crtn.S"
1411 "glibc/sysdeps/m68k/m680x0/sysdep.h"
1412 "glibc/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h"
1413 "glibc/sysdeps/m68k/start.S"
1414 "glibc/sysdeps/m68k/symbol-hacks.h"
1415 "glibc/sysdeps/m68k/sysdep.h"
1416 "glibc/sysdeps/mach/hurd/bits/stat.h"
1417 "glibc/sysdeps/mach/hurd/bits/typesizes.h"
1418 "glibc/sysdeps/mach/hurd/dl-sysdep.h"
1419 "glibc/sysdeps/mach/hurd/kernel-features.h"
1420 "glibc/sysdeps/mach/i386/sysdep.h"
1421 "glibc/sysdeps/mach/libc-lock.h"
1422 "glibc/sysdeps/mach/sys/syscall.h"
1423 "glibc/sysdeps/mach/sysdep.h"
1424 "glibc/sysdeps/microblaze/bits/endian.h"
1425 "glibc/sysdeps/microblaze/crti.S"
1426 "glibc/sysdeps/microblaze/crtn.S"
1427 "glibc/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h"
1428 "glibc/sysdeps/microblaze/start.S"
1429 "glibc/sysdeps/microblaze/sysdep.h"
1430 "glibc/sysdeps/mips/bits/endian.h"
1431 "glibc/sysdeps/mips/dl-dtprocnum.h"
1432 "glibc/sysdeps/mips/mips32/crti.S"
1433 "glibc/sysdeps/mips/mips32/crtn.S"
1434 "glibc/sysdeps/mips/mips64/n32/crti.S"
1435 "glibc/sysdeps/mips/mips64/n32/crtn.S"
1436 "glibc/sysdeps/mips/mips64/n64/crti.S"
1437 "glibc/sysdeps/mips/mips64/n64/crtn.S"
1438 "glibc/sysdeps/mips/nptl/bits/pthreadtypes-arch.h"
1439 "glibc/sysdeps/mips/start.S"
1440 "glibc/sysdeps/nios2/bits/endian.h"
1441 "glibc/sysdeps/nios2/crti.S"
1442 "glibc/sysdeps/nios2/crtn.S"
1443 "glibc/sysdeps/nios2/dl-sysdep.h"
1444 "glibc/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h"
1445 "glibc/sysdeps/nios2/start.S"
1446 "glibc/sysdeps/nios2/sysdep.h"
1368 "glibc/sysdeps/nptl/bits/pthreadtypes.h"1447 "glibc/sysdeps/nptl/bits/pthreadtypes.h"
1369 "glibc/sysdeps/nptl/bits/thread-shared-types.h"1448 "glibc/sysdeps/nptl/bits/thread-shared-types.h"
1370 "glibc/sysdeps/nptl/libc-lock.h"1449 "glibc/sysdeps/nptl/libc-lock.h"
1371 "glibc/sysdeps/nptl/libc-lockP.h"1450 "glibc/sysdeps/nptl/libc-lockP.h"
1372 "glibc/sysdeps/nptl/lowlevellock.h"
1373 "glibc/sysdeps/nptl/pthread.h"1451 "glibc/sysdeps/nptl/pthread.h"
1374 "glibc/sysdeps/pthread/allocalim.h"1452 "glibc/sysdeps/powerpc/bits/endian.h"
1375 "glibc/sysdeps/unix/sysv/linux/bits/param.h"1453 "glibc/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h"
1376 "glibc/sysdeps/unix/sysv/linux/bits/sched.h"1454 "glibc/sysdeps/powerpc/powerpc32/crti.S"
1377 "glibc/sysdeps/unix/sysv/linux/bits/signum.h"1455 "glibc/sysdeps/powerpc/powerpc32/crtn.S"
1456 "glibc/sysdeps/powerpc/powerpc32/dl-dtprocnum.h"
1457 "glibc/sysdeps/powerpc/powerpc32/start.S"
1458 "glibc/sysdeps/powerpc/powerpc32/symbol-hacks.h"
1459 "glibc/sysdeps/powerpc/powerpc32/sysdep.h"
1460 "glibc/sysdeps/powerpc/powerpc64/crti.S"
1461 "glibc/sysdeps/powerpc/powerpc64/crtn.S"
1462 "glibc/sysdeps/powerpc/powerpc64/dl-dtprocnum.h"
1463 "glibc/sysdeps/powerpc/powerpc64/start.S"
1464 "glibc/sysdeps/powerpc/powerpc64/sysdep.h"
1465 "glibc/sysdeps/powerpc/sysdep.h"
1466 "glibc/sysdeps/riscv/bits/endian.h"
1467 "glibc/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h"
1468 "glibc/sysdeps/riscv/start.S"
1469 "glibc/sysdeps/s390/bits/endian.h"
1470 "glibc/sysdeps/s390/nptl/bits/pthreadtypes-arch.h"
1471 "glibc/sysdeps/s390/s390-32/crti.S"
1472 "glibc/sysdeps/s390/s390-32/crtn.S"
1473 "glibc/sysdeps/s390/s390-32/dl-sysdep.h"
1474 "glibc/sysdeps/s390/s390-32/start.S"
1475 "glibc/sysdeps/s390/s390-32/symbol-hacks.h"
1476 "glibc/sysdeps/s390/s390-32/sysdep.h"
1477 "glibc/sysdeps/s390/s390-64/crti.S"
1478 "glibc/sysdeps/s390/s390-64/crtn.S"
1479 "glibc/sysdeps/s390/s390-64/start.S"
1480 "glibc/sysdeps/s390/s390-64/sysdep.h"
1481 "glibc/sysdeps/sh/bits/endian.h"
1482 "glibc/sysdeps/sh/crti.S"
1483 "glibc/sysdeps/sh/crtn.S"
1484 "glibc/sysdeps/sh/nptl/bits/pthreadtypes-arch.h"
1485 "glibc/sysdeps/sh/start.S"
1486 "glibc/sysdeps/sh/sysdep.h"
1487 "glibc/sysdeps/sparc/bits/endian.h"
1488 "glibc/sysdeps/sparc/crti.S"
1489 "glibc/sysdeps/sparc/crtn.S"
1490 "glibc/sysdeps/sparc/dl-dtprocnum.h"
1491 "glibc/sysdeps/sparc/dl-sysdep.h"
1492 "glibc/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h"
1493 "glibc/sysdeps/sparc/sparc32/start.S"
1494 "glibc/sysdeps/sparc/sparc64/start.S"
1495 "glibc/sysdeps/sparc/sysdep.h"
1496 "glibc/sysdeps/unix/alpha/sysdep.h"
1497 "glibc/sysdeps/unix/arm/sysdep.h"
1498 "glibc/sysdeps/unix/i386/sysdep.h"
1499 "glibc/sysdeps/unix/mips/mips32/sysdep.h"
1500 "glibc/sysdeps/unix/mips/mips64/n32/sysdep.h"
1501 "glibc/sysdeps/unix/mips/mips64/n64/sysdep.h"
1502 "glibc/sysdeps/unix/mips/sysdep.h"
1503 "glibc/sysdeps/unix/powerpc/sysdep.h"
1504 "glibc/sysdeps/unix/sh/sysdep.h"
1505 "glibc/sysdeps/unix/sysdep.h"
1506 "glibc/sysdeps/unix/sysv/linux/aarch64/asm/unistd.h"
1507 "glibc/sysdeps/unix/sysv/linux/aarch64/kernel-features.h"
1508 "glibc/sysdeps/unix/sysv/linux/aarch64/sys/elf.h"
1509 "glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h"
1510 "glibc/sysdeps/unix/sysv/linux/alpha/asm/unistd.h"
1511 "glibc/sysdeps/unix/sysv/linux/alpha/bits/stat.h"
1512 "glibc/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h"
1513 "glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h"
1514 "glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h"
1515 "glibc/sysdeps/unix/sysv/linux/arm/asm/unistd.h"
1516 "glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h"
1517 "glibc/sysdeps/unix/sysv/linux/arm/sys/elf.h"
1518 "glibc/sysdeps/unix/sysv/linux/arm/sysdep.h"
1378 "glibc/sysdeps/unix/sysv/linux/bits/stat.h"1519 "glibc/sysdeps/unix/sysv/linux/bits/stat.h"
1379 "glibc/sysdeps/unix/sysv/linux/bits/time.h"
1380 "glibc/sysdeps/unix/sysv/linux/bits/timex.h"1520 "glibc/sysdeps/unix/sysv/linux/bits/timex.h"
1521 "glibc/sysdeps/unix/sysv/linux/csky/asm/unistd.h"
1522 "glibc/sysdeps/unix/sysv/linux/csky/kernel-features.h"
1523 "glibc/sysdeps/unix/sysv/linux/csky/sysdep.h"
1524 "glibc/sysdeps/unix/sysv/linux/dl-sysdep.h"
1381 "glibc/sysdeps/unix/sysv/linux/generic/bits/stat.h"1525 "glibc/sysdeps/unix/sysv/linux/generic/bits/stat.h"
1526 "glibc/sysdeps/unix/sysv/linux/generic/bits/typesizes.h"
1527 "glibc/sysdeps/unix/sysv/linux/generic/sysdep.h"
1528 "glibc/sysdeps/unix/sysv/linux/hppa/kernel-features.h"
1529 "glibc/sysdeps/unix/sysv/linux/hppa/pthread.h"
1530 "glibc/sysdeps/unix/sysv/linux/hppa/sysdep.h"
1531 "glibc/sysdeps/unix/sysv/linux/i386/dl-sysdep.h"
1532 "glibc/sysdeps/unix/sysv/linux/i386/kernel-features.h"
1533 "glibc/sysdeps/unix/sysv/linux/i386/sysdep.h"
1534 "glibc/sysdeps/unix/sysv/linux/ia64/asm/break.h"
1535 "glibc/sysdeps/unix/sysv/linux/ia64/asm/unistd.h"
1536 "glibc/sysdeps/unix/sysv/linux/ia64/bits/endian.h"
1537 "glibc/sysdeps/unix/sysv/linux/ia64/bits/stat.h"
1538 "glibc/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h"
1539 "glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h"
1540 "glibc/sysdeps/unix/sysv/linux/ia64/sysdep.h"
1541 "glibc/sysdeps/unix/sysv/linux/include/asm-generic/unistd.h"
1542 "glibc/sysdeps/unix/sysv/linux/include/asm/unistd_32.h"
1543 "glibc/sysdeps/unix/sysv/linux/include/asm/unistd_64.h"
1544 "glibc/sysdeps/unix/sysv/linux/include/bits/syscall.h"
1382 "glibc/sysdeps/unix/sysv/linux/include/sys/timex.h"1545 "glibc/sysdeps/unix/sysv/linux/include/sys/timex.h"
1546 "glibc/sysdeps/unix/sysv/linux/kernel-features.h"
1547 "glibc/sysdeps/unix/sysv/linux/m68k/asm/unistd.h"
1548 "glibc/sysdeps/unix/sysv/linux/m68k/bits/stat.h"
1549 "glibc/sysdeps/unix/sysv/linux/m68k/coldfire/sysdep.h"
1550 "glibc/sysdeps/unix/sysv/linux/m68k/kernel-features.h"
1551 "glibc/sysdeps/unix/sysv/linux/m68k/m680x0/sysdep.h"
1552 "glibc/sysdeps/unix/sysv/linux/m68k/sysdep.h"
1553 "glibc/sysdeps/unix/sysv/linux/microblaze/asm/unistd.h"
1554 "glibc/sysdeps/unix/sysv/linux/microblaze/bits/stat.h"
1555 "glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h"
1556 "glibc/sysdeps/unix/sysv/linux/microblaze/sysdep.h"
1557 "glibc/sysdeps/unix/sysv/linux/mips/asm/sgidefs.h"
1558 "glibc/sysdeps/unix/sysv/linux/mips/asm/unistd.h"
1559 "glibc/sysdeps/unix/sysv/linux/mips/bits/stat.h"
1560 "glibc/sysdeps/unix/sysv/linux/mips/kernel-features.h"
1561 "glibc/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h"
1562 "glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h"
1563 "glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h"
1564 "glibc/sysdeps/unix/sysv/linux/nios2/asm/unistd.h"
1565 "glibc/sysdeps/unix/sysv/linux/nios2/sysdep.h"
1566 "glibc/sysdeps/unix/sysv/linux/powerpc/asm/unistd.h"
1567 "glibc/sysdeps/unix/sysv/linux/powerpc/bits/stat.h"
1568 "glibc/sysdeps/unix/sysv/linux/powerpc/kernel-features.h"
1569 "glibc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h"
1570 "glibc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h"
1571 "glibc/sysdeps/unix/sysv/linux/riscv/asm/unistd.h"
1572 "glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h"
1573 "glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h"
1574 "glibc/sysdeps/unix/sysv/linux/s390/asm/unistd.h"
1575 "glibc/sysdeps/unix/sysv/linux/s390/bits/stat.h"
1576 "glibc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h"
1577 "glibc/sysdeps/unix/sysv/linux/s390/kernel-features.h"
1578 "glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h"
1579 "glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h"
1580 "glibc/sysdeps/unix/sysv/linux/s390/sys/elf.h"
1581 "glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h"
1582 "glibc/sysdeps/unix/sysv/linux/sh/sh4/sysdep.h"
1583 "glibc/sysdeps/unix/sysv/linux/sh/sysdep.h"
1584 "glibc/sysdeps/unix/sysv/linux/sparc/asm/unistd.h"
1585 "glibc/sysdeps/unix/sysv/linux/sparc/bits/stat.h"
1586 "glibc/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h"
1587 "glibc/sysdeps/unix/sysv/linux/sparc/kernel-features.h"
1588 "glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h"
1589 "glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h"
1590 "glibc/sysdeps/unix/sysv/linux/sparc/sysdep.h"
1591 "glibc/sysdeps/unix/sysv/linux/sys/syscall.h"
1383 "glibc/sysdeps/unix/sysv/linux/sys/timex.h"1592 "glibc/sysdeps/unix/sysv/linux/sys/timex.h"
1593 "glibc/sysdeps/unix/sysv/linux/sysdep.h"
1594 "glibc/sysdeps/unix/sysv/linux/x86/asm/unistd.h"
1384 "glibc/sysdeps/unix/sysv/linux/x86/bits/stat.h"1595 "glibc/sysdeps/unix/sysv/linux/x86/bits/stat.h"
1385 "glibc/sysdeps/unix/sysv/linux/x86/bits/typesizes.h"1596 "glibc/sysdeps/unix/sysv/linux/x86/bits/typesizes.h"
1386 "glibc/sysdeps/unix/sysv/linux/x86/sys/elf.h"1597 "glibc/sysdeps/unix/sysv/linux/x86/sys/elf.h"
1387 "glibc/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h"1598 "glibc/sysdeps/unix/sysv/linux/x86_64/kernel-features.h"
1599 "glibc/sysdeps/unix/sysv/linux/x86_64/sysdep.h"
1600 "glibc/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h"
1601 "glibc/sysdeps/unix/x86_64/sysdep.h"
1388 "glibc/sysdeps/x86/bits/endian.h"1602 "glibc/sysdeps/x86/bits/endian.h"
1389 "glibc/sysdeps/x86/bits/floatn.h"
1390 "glibc/sysdeps/x86/bits/select.h"1603 "glibc/sysdeps/x86/bits/select.h"
1391 "glibc/sysdeps/x86/bits/setjmp.h"
1392 "glibc/sysdeps/x86/bits/wordsize.h"1604 "glibc/sysdeps/x86/bits/wordsize.h"
1393 "glibc/sysdeps/x86/nptl/bits/pthreadtypes-arch.h"1605 "glibc/sysdeps/x86/nptl/bits/pthreadtypes-arch.h"
1394 "glibc/sysdeps/x86/sysdep.h"1606 "glibc/sysdeps/x86/sysdep.h"
1395 "glibc/sysdeps/x86_64/crti.S"1607 "glibc/sysdeps/x86_64/crti.S"
1396 "glibc/sysdeps/x86_64/crtn.S"1608 "glibc/sysdeps/x86_64/crtn.S"
1397 "glibc/sysdeps/x86_64/stackinfo.h"
1398 "glibc/sysdeps/x86_64/start.S"1609 "glibc/sysdeps/x86_64/start.S"
1399 "glibc/sysdeps/x86_64/sysdep.h"1610 "glibc/sysdeps/x86_64/sysdep.h"
1611 "glibc/sysdeps/x86_64/x32/symbol-hacks.h"
1612 "glibc/sysdeps/x86_64/x32/sysdep.h"
1400 "glibc/time/bits/types/clock_t.h"1613 "glibc/time/bits/types/clock_t.h"
1401 "glibc/time/bits/types/clockid_t.h"1614 "glibc/time/bits/types/clockid_t.h"
1402 "glibc/time/bits/types/struct_itimerspec.h"1615 "glibc/time/bits/types/struct_itimerspec.h"
...@@ -1405,8 +1618,6 @@ set(ZIG_LIBC_FILES...@@ -1405,8 +1618,6 @@ set(ZIG_LIBC_FILES
1405 "glibc/time/bits/types/struct_tm.h"1618 "glibc/time/bits/types/struct_tm.h"
1406 "glibc/time/bits/types/time_t.h"1619 "glibc/time/bits/types/time_t.h"
1407 "glibc/time/bits/types/timer_t.h"1620 "glibc/time/bits/types/timer_t.h"
1408 "glibc/time/sys/time.h"
1409 "glibc/time/time.h"
1410)1621)
14111622
1412set(ZIG_LIBUNWIND_FILES1623set(ZIG_LIBUNWIND_FILES
libc/glibc/bits/param.h deleted-33
...@@ -1,33 +0,0 @@
1/* Old-style Unix parameters and limits. Stub version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
21#endif
22
23/* This header is expected to define a few particular macros.
24
25 The traditional BSD macros that correspond directly to POSIX <limits.h>
26 macros don't need to be defined here if <bits/local_lim.h> defines the
27 POSIX limit macro, as the common <sys/param.h> code will define each
28 traditional name to its POSIX name if available.
29
30 This file should define at least:
31
32 EXEC_PAGESIZE
33*/
libc/glibc/bits/sched.h deleted-34
...@@ -1,34 +0,0 @@
1/* Definitions of constants and data structure for POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_SCHED_H
21#define _BITS_SCHED_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/sched.h> directly; use <sched.h> instead."
25#endif
26
27/* Scheduling algorithms. */
28#define SCHED_OTHER 0
29#define SCHED_FIFO 1
30#define SCHED_RR 2
31
32#include <bits/types/struct_sched_param.h>
33
34#endif /* bits/sched.h */
libc/glibc/bits/setjmp.h deleted-7
...@@ -1,7 +0,0 @@
1/* Define the machine-dependent type `jmp_buf'. Stub version. */
2
3#ifndef _SETJMP_H
4# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
5#endif
6
7typedef int __jmp_buf[1];
libc/glibc/bits/signum.h deleted-32
...@@ -1,32 +0,0 @@
1/* Signal number constants. Generic version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_H
20#define _BITS_SIGNUM_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum.h> directly; use <signal.h> instead."
24#endif
25
26#include <bits/signum-generic.h>
27
28/* This operating system does not need to override any of the generic
29 signal number assignments in bits/signum-generic.h, nor to add any
30 additional signal constants. */
31
32#endif /* bits/signum.h. */
libc/glibc/bits/time.h deleted-64
...@@ -1,64 +0,0 @@
1/* System-dependent timing definitions. Generic version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <time.h> instead.
21 */
22
23#ifndef _BITS_TIME_H
24#define _BITS_TIME_H 1
25
26#include <bits/types.h>
27
28/* ISO/IEC 9899:1999 7.23.1: Components of time
29 The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
30 the number per second of the value returned by the `clock' function. */
31/* CAE XSH, Issue 4, Version 2: <time.h>
32 The value of CLOCKS_PER_SEC is required to be 1 million on all
33 XSI-conformant systems. */
34#define CLOCKS_PER_SEC ((__clock_t) 1000000)
35
36#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
37 && !defined __USE_XOPEN2K
38/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
39 presents the real value for clock ticks per second for the system. */
40extern long int __sysconf (int);
41# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
42#endif
43
44#ifdef __USE_POSIX199309
45/* Identifier for system-wide realtime clock. */
46# define CLOCK_REALTIME 0
47/* Monotonic system-wide clock. */
48# define CLOCK_MONOTONIC 1
49/* High-resolution timer from the CPU. */
50# define CLOCK_PROCESS_CPUTIME_ID 2
51/* Thread-specific CPU-time clock. */
52# define CLOCK_THREAD_CPUTIME_ID 3
53/* Monotonic system-wide clock, not adjusted for frequency scaling. */
54# define CLOCK_MONOTONIC_RAW 4
55/* Identifier for system-wide realtime clock, updated only on ticks. */
56# define CLOCK_REALTIME_COARSE 5
57/* Monotonic system-wide clock, updated only on ticks. */
58# define CLOCK_MONOTONIC_COARSE 6
59
60/* Flag to indicate time is absolute. */
61# define TIMER_ABSTIME 1
62#endif
63
64#endif /* bits/time.h */
libc/glibc/include/sched.h deleted-34
...@@ -1,34 +0,0 @@
1#ifndef _SCHED_H
2#include <posix/sched.h>
3
4#ifndef _ISOMAC
5/* Now define the internal interfaces. */
6extern int __sched_setparam (__pid_t __pid,
7 const struct sched_param *__param);
8libc_hidden_proto (__sched_setparam)
9extern int __sched_getparam (__pid_t __pid, struct sched_param *__param);
10extern int __sched_setscheduler (__pid_t __pid, int __policy,
11 const struct sched_param *__param);
12libc_hidden_proto (__sched_setscheduler)
13extern int __sched_getscheduler (__pid_t __pid);
14extern int __sched_yield (void);
15libc_hidden_proto (__sched_yield)
16extern int __sched_get_priority_max (int __algorithm);
17libc_hidden_proto (__sched_get_priority_max)
18extern int __sched_get_priority_min (int __algorithm);
19libc_hidden_proto (__sched_get_priority_min)
20extern int __sched_rr_get_interval (__pid_t __pid, struct timespec *__t);
21
22/* These are Linux specific. */
23extern int __clone (int (*__fn) (void *__arg), void *__child_stack,
24 int __flags, void *__arg, ...);
25libc_hidden_proto (__clone)
26extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
27 size_t __child_stack_size, int __flags, void *__arg, ...);
28libc_hidden_proto (__clone2)
29/* NB: Can't use "__typeof__ (getcpu)" since getcpu is Linux specific
30 and Hurd doesn't have it. */
31extern int __getcpu (unsigned int *, unsigned int *);
32libc_hidden_proto (__getcpu)
33#endif
34#endif
libc/glibc/include/setjmp.h deleted-69
...@@ -1,69 +0,0 @@
1#ifndef _SETJMP_H
2#include <setjmp/setjmp.h>
3
4#ifndef _ISOMAC
5/* Now define the internal interfaces. */
6
7/* Internal machine-dependent function to restore context sans signal mask. */
8extern void __longjmp (__jmp_buf __env, int __val)
9 __attribute__ ((__noreturn__)) attribute_hidden;
10
11extern void ____longjmp_chk (__jmp_buf __env, int __val)
12 __attribute__ ((__noreturn__)) attribute_hidden;
13
14/* Internal function to possibly save the current mask of blocked signals
15 in ENV, and always set the flag saying whether or not it was saved.
16 This is used by the machine-dependent definition of `__sigsetjmp'.
17 Always returns zero, for convenience. */
18extern int __sigjmp_save (jmp_buf __env, int __savemask);
19
20extern void _longjmp_unwind (jmp_buf env, int val);
21
22extern void __libc_siglongjmp (sigjmp_buf env, int val)
23 __attribute__ ((noreturn));
24extern void __libc_longjmp (sigjmp_buf env, int val)
25 __attribute__ ((noreturn));
26
27libc_hidden_proto (_setjmp)
28libc_hidden_proto (__sigsetjmp)
29
30# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
31extern __typeof (__sigsetjmp) __sigsetjmp attribute_hidden;
32# endif
33
34/* Check jmp_buf sizes, alignments and offsets. */
35# include <stddef.h>
36# include <jmp_buf-macros.h>
37
38# define STR_HELPER(x) #x
39# define STR(x) STR_HELPER(x)
40
41# define TEST_SIZE(type, size) \
42 _Static_assert (sizeof (type) == size, \
43 "size of " #type " != " \
44 STR (size))
45# define TEST_ALIGN(type, align) \
46 _Static_assert (__alignof__ (type) == align , \
47 "align of " #type " != " \
48 STR (align))
49# define TEST_OFFSET(type, member, offset) \
50 _Static_assert (offsetof (type, member) == offset, \
51 "offset of " #member " field of " #type " != " \
52 STR (offset))
53
54/* Check if jmp_buf have the expected sizes. */
55TEST_SIZE (jmp_buf, JMP_BUF_SIZE);
56TEST_SIZE (sigjmp_buf, SIGJMP_BUF_SIZE);
57
58/* Check if jmp_buf have the expected alignments. */
59TEST_ALIGN (jmp_buf, JMP_BUF_ALIGN);
60TEST_ALIGN (sigjmp_buf, SIGJMP_BUF_ALIGN);
61
62/* Check if internal fields in jmp_buf have the expected offsets. */
63TEST_OFFSET (struct __jmp_buf_tag, __mask_was_saved,
64 MASK_WAS_SAVED_OFFSET);
65TEST_OFFSET (struct __jmp_buf_tag, __saved_mask,
66 SAVED_MASK_OFFSET);
67#endif
68
69#endif
libc/glibc/include/stackinfo.h deleted-42
...@@ -1,42 +0,0 @@
1/* Details about the machine's stack: wrapper header.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _INCLUDE_STACKINFO_H
20#define _INCLUDE_STACKINFO_H 1
21
22/* A sysdeps/.../stackinfo.h file defines details for the CPU.
23 It is obliged to define either _STACK_GROWS_DOWN or _STACK_GROWS_UP. */
24#include_next <stackinfo.h>
25
26#if defined _STACK_GROWS_DOWN && _STACK_GROWS_DOWN
27# ifdef _STACK_GROWS_UP
28# error "stackinfo.h should not define both!"
29# else
30# define _STACK_GROWS_UP 0
31# endif
32#elif defined _STACK_GROWS_UP && _STACK_GROWS_UP
33# ifdef _STACK_GROWS_DOWN
34# error "stackinfo.h should not define both!"
35# else
36# define _STACK_GROWS_DOWN 0
37# endif
38#else
39# error "stackinfo.h must define _STACK_GROWS_UP or _STACK_GROWS_DOWN!"
40#endif
41
42#endif /* include/stackinfo.h */
libc/glibc/include/sys/param.h deleted-1
...@@ -1 +0,0 @@
1#include <misc/sys/param.h>
libc/glibc/include/sys/time.h deleted-43
...@@ -1,43 +0,0 @@
1/* Time function internal interfaces.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_TIME_H
20# include <time/sys/time.h>
21
22# ifndef _ISOMAC
23extern int __gettimeofday (struct timeval *__tv,
24 struct timezone *__tz);
25libc_hidden_proto (__gettimeofday)
26libc_hidden_proto (gettimeofday)
27extern int __settimeofday (const struct timeval *__tv,
28 const struct timezone *__tz)
29 attribute_hidden;
30extern int __adjtime (const struct timeval *__delta,
31 struct timeval *__olddelta);
32extern int __getitimer (enum __itimer_which __which,
33 struct itimerval *__value);
34extern int __setitimer (enum __itimer_which __which,
35 const struct itimerval *__restrict __new,
36 struct itimerval *__restrict __old)
37 attribute_hidden;
38extern int __utimes (const char *__file, const struct timeval __tvp[2])
39 attribute_hidden;
40extern int __futimes (int fd, const struct timeval tvp[2]) attribute_hidden;
41
42# endif
43#endif
libc/glibc/include/syscall.h created+1
...@@ -0,0 +1 @@
1#include <misc/syscall.h>
libc/glibc/include/time.h deleted-159
...@@ -1,159 +0,0 @@
1#ifndef _TIME_H
2#include <time/time.h>
3
4#ifndef _ISOMAC
5# include <bits/types/locale_t.h>
6
7extern __typeof (strftime_l) __strftime_l;
8libc_hidden_proto (__strftime_l)
9extern __typeof (strptime_l) __strptime_l;
10
11libc_hidden_proto (time)
12libc_hidden_proto (asctime)
13libc_hidden_proto (mktime)
14libc_hidden_proto (timelocal)
15libc_hidden_proto (localtime)
16libc_hidden_proto (strftime)
17libc_hidden_proto (strptime)
18
19extern __typeof (clock_getres) __clock_getres;
20extern __typeof (clock_gettime) __clock_gettime;
21libc_hidden_proto (__clock_gettime)
22extern __typeof (clock_settime) __clock_settime;
23extern __typeof (clock_nanosleep) __clock_nanosleep;
24extern __typeof (clock_getcpuclockid) __clock_getcpuclockid;
25
26/* Now define the internal interfaces. */
27struct tm;
28
29/* Defined in mktime.c. */
30extern const unsigned short int __mon_yday[2][13] attribute_hidden;
31
32/* Defined in localtime.c. */
33extern struct tm _tmbuf attribute_hidden;
34
35/* Defined in tzset.c. */
36extern char *__tzstring (const char *string) attribute_hidden;
37
38extern int __use_tzfile attribute_hidden;
39
40extern void __tzfile_read (const char *file, size_t extra,
41 char **extrap) attribute_hidden;
42extern void __tzfile_compute (__time64_t timer, int use_localtime,
43 long int *leap_correct, int *leap_hit,
44 struct tm *tp) attribute_hidden;
45extern void __tzfile_default (const char *std, const char *dst,
46 long int stdoff, long int dstoff)
47 attribute_hidden;
48extern void __tzset_parse_tz (const char *tz) attribute_hidden;
49extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
50 __THROW attribute_hidden;
51
52/* Subroutine of `mktime'. Return the `time_t' representation of TP and
53 normalize TP, given that a `struct tm *' maps to a `time_t' as performed
54 by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */
55extern time_t __mktime_internal (struct tm *__tp,
56 struct tm *(*__func) (const time_t *,
57 struct tm *),
58 long int *__offset) attribute_hidden;
59
60#if __TIMESIZE == 64
61# define __ctime64 ctime
62#else
63extern char *__ctime64 (const __time64_t *__timer) __THROW;
64libc_hidden_proto (__ctime64);
65#endif
66
67#if __TIMESIZE == 64
68# define __ctime64_r ctime_r
69#else
70extern char *__ctime64_r (const __time64_t *__restrict __timer,
71 char *__restrict __buf) __THROW;
72libc_hidden_proto (__ctime64_r);
73#endif
74
75#if __TIMESIZE == 64
76# define __localtime64 localtime
77#else
78extern struct tm *__localtime64 (const __time64_t *__timer);
79libc_hidden_proto (__localtime64)
80#endif
81
82extern struct tm *__localtime_r (const time_t *__timer,
83 struct tm *__tp) attribute_hidden;
84
85#if __TIMESIZE == 64
86# define __localtime64_r __localtime_r
87#else
88extern struct tm *__localtime64_r (const __time64_t *__timer,
89 struct tm *__tp);
90libc_hidden_proto (__localtime64_r)
91#endif
92
93extern struct tm *__gmtime_r (const time_t *__restrict __timer,
94 struct tm *__restrict __tp);
95libc_hidden_proto (__gmtime_r)
96
97#if __TIMESIZE == 64
98# define __gmtime64 gmtime
99#else
100extern struct tm *__gmtime64 (const __time64_t *__timer);
101libc_hidden_proto (__gmtime64)
102#endif
103
104#if __TIMESIZE == 64
105# define __gmtime64_r __gmtime_r
106#else
107extern struct tm *__gmtime64_r (const __time64_t *__restrict __timer,
108 struct tm *__restrict __tp);
109libc_hidden_proto (__gmtime64_r);
110#endif
111
112/* Compute the `struct tm' representation of T,
113 offset OFFSET seconds east of UTC,
114 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
115 Return nonzero if successful. */
116extern int __offtime (__time64_t __timer,
117 long int __offset,
118 struct tm *__tp) attribute_hidden;
119
120extern char *__asctime_r (const struct tm *__tp, char *__buf)
121 attribute_hidden;
122extern void __tzset (void) attribute_hidden;
123
124/* Prototype for the internal function to get information based on TZ. */
125extern struct tm *__tz_convert (__time64_t timer, int use_localtime,
126 struct tm *tp) attribute_hidden;
127
128extern int __nanosleep (const struct timespec *__requested_time,
129 struct timespec *__remaining);
130hidden_proto (__nanosleep)
131extern int __getdate_r (const char *__string, struct tm *__resbufp)
132 attribute_hidden;
133
134
135/* Determine CLK_TCK value. */
136extern int __getclktck (void) attribute_hidden;
137
138
139/* strptime support. */
140extern char * __strptime_internal (const char *rp, const char *fmt,
141 struct tm *tm, void *statep,
142 locale_t locparam) attribute_hidden;
143
144#if __TIMESIZE == 64
145# define __difftime64 __difftime
146#else
147extern double __difftime64 (__time64_t time1, __time64_t time0);
148libc_hidden_proto (__difftime64)
149#endif
150
151extern double __difftime (time_t time1, time_t time0);
152
153
154/* Use in the clock_* functions. Size of the field representing the
155 actual clock ID. */
156#define CLOCK_IDFIELD_SIZE 3
157
158#endif
159#endif
libc/glibc/misc/sys/param.h deleted-106
...@@ -1,106 +0,0 @@
1/* Compatibility header for old-style Unix parameters and limits.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20#define _SYS_PARAM_H 1
21
22#define __need_NULL
23#include <stddef.h>
24
25#include <sys/types.h>
26#include <limits.h>
27#include <endian.h> /* Define BYTE_ORDER et al. */
28#include <signal.h> /* Define NSIG. */
29
30/* This file defines some things in system-specific ways. */
31#include <bits/param.h>
32
33
34/* BSD names for some <limits.h> values. */
35
36#define NBBY CHAR_BIT
37
38#if !defined NGROUPS && defined NGROUPS_MAX
39# define NGROUPS NGROUPS_MAX
40#endif
41#if !defined MAXSYMLINKS && defined SYMLOOP_MAX
42# define MAXSYMLINKS SYMLOOP_MAX
43#endif
44#if !defined CANBSIZ && defined MAX_CANON
45# define CANBSIZ MAX_CANON
46#endif
47#if !defined MAXPATHLEN && defined PATH_MAX
48# define MAXPATHLEN PATH_MAX
49#endif
50#if !defined NOFILE && defined OPEN_MAX
51# define NOFILE OPEN_MAX
52#endif
53#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
54# define MAXHOSTNAMELEN HOST_NAME_MAX
55#endif
56#ifndef NCARGS
57# ifdef ARG_MAX
58# define NCARGS ARG_MAX
59# else
60/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
61 compare against some fixed limit. */
62# define NCARGS INT_MAX
63# endif
64#endif
65
66
67/* Magical constants. */
68#ifndef NOGROUP
69# define NOGROUP 65535 /* Marker for empty group set member. */
70#endif
71#ifndef NODEV
72# define NODEV ((dev_t) -1) /* Non-existent device. */
73#endif
74
75
76/* Unit of `st_blocks'. */
77#ifndef DEV_BSIZE
78# define DEV_BSIZE 512
79#endif
80
81
82/* Bit map related macros. */
83#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
84#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
85#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
86#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
87
88/* Macros for counting and rounding. */
89#ifndef howmany
90# define howmany(x, y) (((x) + ((y) - 1)) / (y))
91#endif
92#ifdef __GNUC__
93# define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
94 ? (((x) + (y) - 1) & ~((y) - 1)) \
95 : ((((x) + ((y) - 1)) / (y)) * (y)))
96#else
97# define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
98#endif
99#define powerof2(x) ((((x) - 1) & (x)) == 0)
100
101/* Macros for min/max. */
102#define MIN(a,b) (((a)<(b))?(a):(b))
103#define MAX(a,b) (((a)>(b))?(a):(b))
104
105
106#endif /* sys/param.h */
libc/glibc/misc/syscall.h created+1
...@@ -0,0 +1 @@
1#include <sys/syscall.h>
libc/glibc/posix/sched.h deleted-131
...@@ -1,131 +0,0 @@
1/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SCHED_H
20#define _SCHED_H 1
21
22#include <features.h>
23
24/* Get type definitions. */
25#include <bits/types.h>
26
27#define __need_size_t
28#define __need_NULL
29#include <stddef.h>
30
31#include <bits/types/time_t.h>
32#include <bits/types/struct_timespec.h>
33#ifndef __USE_XOPEN2K
34# include <time.h>
35#endif
36
37#ifndef __pid_t_defined
38typedef __pid_t pid_t;
39# define __pid_t_defined
40#endif
41
42/* Get system specific constant and data structure definitions. */
43#include <bits/sched.h>
44#include <bits/cpu-set.h>
45
46/* Backward compatibility. */
47#define sched_priority sched_priority
48#define __sched_priority sched_priority
49
50
51__BEGIN_DECLS
52
53/* Set scheduling parameters for a process. */
54extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
55 __THROW;
56
57/* Retrieve scheduling parameters for a particular process. */
58extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
59
60/* Set scheduling algorithm and/or parameters for a process. */
61extern int sched_setscheduler (__pid_t __pid, int __policy,
62 const struct sched_param *__param) __THROW;
63
64/* Retrieve scheduling algorithm for a particular purpose. */
65extern int sched_getscheduler (__pid_t __pid) __THROW;
66
67/* Yield the processor. */
68extern int sched_yield (void) __THROW;
69
70/* Get maximum priority value for a scheduler. */
71extern int sched_get_priority_max (int __algorithm) __THROW;
72
73/* Get minimum priority value for a scheduler. */
74extern int sched_get_priority_min (int __algorithm) __THROW;
75
76/* Get the SCHED_RR interval for the named process. */
77extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
78
79
80#ifdef __USE_GNU
81/* Access macros for `cpu_set'. */
82# define CPU_SETSIZE __CPU_SETSIZE
83# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
84# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
85# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
86 cpusetp)
87# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
88# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
89
90# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
91# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
92# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
93 cpusetp)
94# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
95# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
96
97# define CPU_EQUAL(cpusetp1, cpusetp2) \
98 __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
99# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
100 __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
101
102# define CPU_AND(destset, srcset1, srcset2) \
103 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
104# define CPU_OR(destset, srcset1, srcset2) \
105 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
106# define CPU_XOR(destset, srcset1, srcset2) \
107 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
108# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
109 __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
110# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
111 __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
112# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
113 __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
114
115# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
116# define CPU_ALLOC(count) __CPU_ALLOC (count)
117# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
118
119
120/* Set the CPU affinity for a task */
121extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
122 const cpu_set_t *__cpuset) __THROW;
123
124/* Get the CPU affinity for a task */
125extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
126 cpu_set_t *__cpuset) __THROW;
127#endif
128
129__END_DECLS
130
131#endif /* sched.h */
libc/glibc/setjmp/setjmp.h deleted-105
...@@ -1,105 +0,0 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>
20 */
21
22#ifndef _SETJMP_H
23#define _SETJMP_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/setjmp.h> /* Get `__jmp_buf'. */
30#include <bits/types/__sigset_t.h>
31
32/* Calling environment, plus possibly a saved signal mask. */
33struct __jmp_buf_tag
34 {
35 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
36 assume that a `jmp_buf' begins with a `__jmp_buf' and that
37 `__mask_was_saved' follows it. Do not move these members
38 or add others before it. */
39 __jmp_buf __jmpbuf; /* Calling environment. */
40 int __mask_was_saved; /* Saved the signal mask? */
41 __sigset_t __saved_mask; /* Saved signal mask. */
42 };
43
44
45typedef struct __jmp_buf_tag jmp_buf[1];
46
47/* Store the calling environment in ENV, also saving the signal mask.
48 Return 0. */
49extern int setjmp (jmp_buf __env) __THROWNL;
50
51/* Store the calling environment in ENV, also saving the
52 signal mask if SAVEMASK is nonzero. Return 0.
53 This is the internal name for `sigsetjmp'. */
54extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
55
56/* Store the calling environment in ENV, not saving the signal mask.
57 Return 0. */
58extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
59
60/* Do not save the signal mask. This is equivalent to the `_setjmp'
61 BSD function. */
62#define setjmp(env) _setjmp (env)
63
64
65/* Jump to the environment saved in ENV, making the
66 `setjmp' call there return VAL, or 1 if VAL is 0. */
67extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
68 __THROWNL __attribute__ ((__noreturn__));
69
70#if defined __USE_MISC || defined __USE_XOPEN
71/* Same. Usually `_longjmp' is used with `_setjmp', which does not save
72 the signal mask. But it is how ENV was saved that determines whether
73 `longjmp' restores the mask; `_longjmp' is just an alias. */
74extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
75 __THROWNL __attribute__ ((__noreturn__));
76#endif
77
78
79#ifdef __USE_POSIX
80/* Use the same type for `jmp_buf' and `sigjmp_buf'.
81 The `__mask_was_saved' flag determines whether
82 or not `longjmp' will restore the signal mask. */
83typedef struct __jmp_buf_tag sigjmp_buf[1];
84
85/* Store the calling environment in ENV, also saving the
86 signal mask if SAVEMASK is nonzero. Return 0. */
87# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
88
89/* Jump to the environment saved in ENV, making the
90 sigsetjmp call there return VAL, or 1 if VAL is 0.
91 Restore the signal mask if that sigsetjmp call saved it.
92 This is just an alias `longjmp'. */
93extern void siglongjmp (sigjmp_buf __env, int __val)
94 __THROWNL __attribute__ ((__noreturn__));
95#endif /* Use POSIX. */
96
97
98/* Define helper functions to catch unsafe code. */
99#if __USE_FORTIFY_LEVEL > 0
100# include <bits/setjmp2.h>
101#endif
102
103__END_DECLS
104
105#endif /* setjmp.h */
libc/glibc/sysdeps/aarch64/bits/endian.h created+30
...@@ -0,0 +1,30 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ENDIAN_H
20# error "Never use <bits/endian.h> directly; include <endian.h> instead."
21#endif
22
23/* AArch64 can be either big or little endian. */
24#ifdef __AARCH64EB__
25# define __BYTE_ORDER __BIG_ENDIAN
26#else
27# define __BYTE_ORDER __LITTLE_ENDIAN
28#endif
29
30#define __FLOAT_WORD_ORDER __BYTE_ORDER
libc/glibc/sysdeps/aarch64/crti.S created+93
...@@ -0,0 +1,93 @@
1/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37/* crti.S puts a function prologue at the beginning of the .init and
38 .fini sections and defines global symbols for those addresses, so
39 they can be called as functions. The symbols _init and _fini are
40 magic and cause the linker to emit DT_INIT and DT_FINI. */
41
42#include <sysdep.h>
43#include <libc-symbols.h>
44
45#ifndef PREINIT_FUNCTION
46# define PREINIT_FUNCTION __gmon_start__
47#endif
48
49#ifndef PREINIT_FUNCTION_WEAK
50# define PREINIT_FUNCTION_WEAK 1
51#endif
52
53#if PREINIT_FUNCTION_WEAK
54 weak_extern (PREINIT_FUNCTION)
55#else
56 .hidden PREINIT_FUNCTION
57#endif
58
59#if PREINIT_FUNCTION_WEAK
60 .align 2
61 .type call_weak_fn, %function
62call_weak_fn:
63 adrp x0, :got:PREINIT_FUNCTION
64 ldr PTR_REG (0), [x0, #:got_lo12:PREINIT_FUNCTION]
65 cbz x0, 1f
66 b PREINIT_FUNCTION
671:
68 RET
69 .size call_weak_fn, .-call_weak_fn
70#endif
71
72 .section .init,"ax",%progbits
73 .align 2
74 .global _init
75 .hidden _init
76 .type _init, %function
77_init:
78 stp x29, x30, [sp, -16]!
79 mov x29, sp
80#if PREINIT_FUNCTION_WEAK
81 bl call_weak_fn
82#else
83 bl PREINIT_FUNCTION
84#endif
85
86 .section .fini,"ax",%progbits
87 .align 2
88 .global _fini
89 .hidden _fini
90 .type _fini, %function
91_fini:
92 stp x29, x30, [sp, -16]!
93 mov x29, sp
libc/glibc/sysdeps/aarch64/crtn.S created+46
...@@ -0,0 +1,46 @@
1/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37/* crtn.S puts function epilogues in the .init and .fini sections
38 corresponding to the prologues in crti.S. */
39
40 .section .init,"ax",%progbits
41 ldp x29, x30, [sp], 16
42 RET
43
44 .section .fini,"ax",%progbits
45 ldp x29, x30, [sp], 16
46 RET
libc/glibc/sysdeps/aarch64/dl-sysdep.h created+25
...@@ -0,0 +1,25 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
24
25#define DL_EXTERN_PROTECTED_DATA
libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h created+71
...@@ -0,0 +1,71 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <endian.h>
23
24#ifdef __ILP32__
25# define __SIZEOF_PTHREAD_ATTR_T 32
26# define __SIZEOF_PTHREAD_MUTEX_T 32
27# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
28# define __SIZEOF_PTHREAD_CONDATTR_T 4
29# define __SIZEOF_PTHREAD_RWLOCK_T 48
30# define __SIZEOF_PTHREAD_BARRIER_T 20
31# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
32#else
33# define __SIZEOF_PTHREAD_ATTR_T 64
34# define __SIZEOF_PTHREAD_MUTEX_T 48
35# define __SIZEOF_PTHREAD_MUTEXATTR_T 8
36# define __SIZEOF_PTHREAD_CONDATTR_T 8
37# define __SIZEOF_PTHREAD_RWLOCK_T 56
38# define __SIZEOF_PTHREAD_BARRIER_T 32
39# define __SIZEOF_PTHREAD_BARRIERATTR_T 8
40#endif
41#define __SIZEOF_PTHREAD_COND_T 48
42#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
43
44/* Definitions for internal mutex struct. */
45#define __PTHREAD_COMPAT_PADDING_MID
46#define __PTHREAD_COMPAT_PADDING_END
47#define __PTHREAD_MUTEX_LOCK_ELISION 0
48#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
49#define __PTHREAD_MUTEX_USE_UNION 0
50
51#define __LOCK_ALIGNMENT
52#define __ONCE_ALIGNMENT
53
54struct __pthread_rwlock_arch_t
55{
56 unsigned int __readers;
57 unsigned int __writers;
58 unsigned int __wrphase_futex;
59 unsigned int __writers_futex;
60 unsigned int __pad3;
61 unsigned int __pad4;
62 int __cur_writer;
63 int __shared;
64 unsigned long int __pad1;
65 unsigned long int __pad2;
66 unsigned int __flags;
67};
68
69#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
70
71#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/aarch64/start.S created+112
...@@ -0,0 +1,112 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdep.h>
20
21/* This is the canonical entry point, usually the first thing in the text
22 segment.
23
24 Note that the code in the .init section has already been run.
25 This includes _init and _libc_init
26
27
28 At this entry point, most registers' values are unspecified, except:
29
30 x0/w0 Contains a function pointer to be registered with `atexit'.
31 This is how the dynamic linker arranges to have DT_FINI
32 functions called for shared libraries that have been loaded
33 before this code runs.
34
35 sp The stack contains the arguments and environment:
36 0(sp) argc
37 8(sp) argv[0]
38 ...
39 (8*argc)(sp) NULL
40 (8*(argc+1))(sp) envp[0]
41 ...
42 NULL
43 */
44
45 .text
46 .globl _start
47 .type _start,#function
48_start:
49 /* Create an initial frame with 0 LR and FP */
50 mov x29, #0
51 mov x30, #0
52
53 /* Setup rtld_fini in argument register */
54 mov x5, x0
55
56 /* Load argc and a pointer to argv */
57 ldr PTR_REG (1), [sp, #0]
58 add x2, sp, #PTR_SIZE
59
60 /* Setup stack limit in argument register */
61 mov x6, sp
62
63#ifdef PIC
64# ifdef SHARED
65 adrp x0, :got:main
66 ldr PTR_REG (0), [x0, #:got_lo12:main]
67
68 adrp x3, :got:__libc_csu_init
69 ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
70
71 adrp x4, :got:__libc_csu_fini
72 ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
73# else
74 adrp x0, __wrap_main
75 add x0, x0, :lo12:__wrap_main
76 adrp x3, __libc_csu_init
77 add x3, x3, :lo12:__libc_csu_init
78 adrp x4, __libc_csu_fini
79 add x4, x4, :lo12:__libc_csu_fini
80# endif
81#else
82 /* Set up the other arguments in registers */
83 MOVL (0, main)
84 MOVL (3, __libc_csu_init)
85 MOVL (4, __libc_csu_fini)
86#endif
87
88 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
89 stack_end) */
90
91 /* Let the libc call main and exit with its return code. */
92 bl __libc_start_main
93
94 /* should never get here....*/
95 bl abort
96
97#if defined PIC && !defined SHARED
98 /* When main is not defined in the executable but in a shared library
99 then a wrapper is needed in crt1.o of the static-pie enabled libc,
100 because crt1.o and rcrt1.o share code and the later must avoid the
101 use of GOT relocations before __libc_start_main is called. */
102__wrap_main:
103 b main
104#endif
105
106 /* Define a symbol for the first piece of initialized data. */
107 .data
108 .globl __data_start
109__data_start:
110 .long 0
111 .weak data_start
112 data_start = __data_start
libc/glibc/sysdeps/aarch64/sysdep.h created+162
...@@ -0,0 +1,162 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _AARCH64_SYSDEP_H
20#define _AARCH64_SYSDEP_H
21
22#include <sysdeps/generic/sysdep.h>
23
24#ifdef __LP64__
25# define AARCH64_R(NAME) R_AARCH64_ ## NAME
26# define PTR_REG(n) x##n
27# define PTR_LOG_SIZE 3
28# define DELOUSE(n)
29#else
30# define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME
31# define PTR_REG(n) w##n
32# define PTR_LOG_SIZE 2
33# define DELOUSE(n) mov w##n, w##n
34#endif
35
36#define PTR_SIZE (1<<PTR_LOG_SIZE)
37
38#ifdef __ASSEMBLER__
39
40/* Syntactic details of assembler. */
41
42#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
43
44/* Define an entry point visible from C. */
45#define ENTRY(name) \
46 .globl C_SYMBOL_NAME(name); \
47 .type C_SYMBOL_NAME(name),%function; \
48 .align 4; \
49 C_LABEL(name) \
50 cfi_startproc; \
51 CALL_MCOUNT
52
53/* Define an entry point visible from C. */
54#define ENTRY_ALIGN(name, align) \
55 .globl C_SYMBOL_NAME(name); \
56 .type C_SYMBOL_NAME(name),%function; \
57 .p2align align; \
58 C_LABEL(name) \
59 cfi_startproc; \
60 CALL_MCOUNT
61
62/* Define an entry point visible from C with a specified alignment and
63 pre-padding with NOPs. This can be used to ensure that a critical
64 loop within a function is cache line aligned. Note this version
65 does not adjust the padding if CALL_MCOUNT is defined. */
66
67#define ENTRY_ALIGN_AND_PAD(name, align, padding) \
68 .globl C_SYMBOL_NAME(name); \
69 .type C_SYMBOL_NAME(name),%function; \
70 .p2align align; \
71 .rep padding; \
72 nop; \
73 .endr; \
74 C_LABEL(name) \
75 cfi_startproc; \
76 CALL_MCOUNT
77
78#undef END
79#define END(name) \
80 cfi_endproc; \
81 ASM_SIZE_DIRECTIVE(name)
82
83/* If compiled for profiling, call `mcount' at the start of each function. */
84#ifdef PROF
85# define CALL_MCOUNT \
86 str x30, [sp, #-80]!; \
87 cfi_adjust_cfa_offset (80); \
88 cfi_rel_offset (x30, 0); \
89 stp x0, x1, [sp, #16]; \
90 cfi_rel_offset (x0, 16); \
91 cfi_rel_offset (x1, 24); \
92 stp x2, x3, [sp, #32]; \
93 cfi_rel_offset (x2, 32); \
94 cfi_rel_offset (x3, 40); \
95 stp x4, x5, [sp, #48]; \
96 cfi_rel_offset (x4, 48); \
97 cfi_rel_offset (x5, 56); \
98 stp x6, x7, [sp, #64]; \
99 cfi_rel_offset (x6, 64); \
100 cfi_rel_offset (x7, 72); \
101 mov x0, x30; \
102 bl mcount; \
103 ldp x0, x1, [sp, #16]; \
104 cfi_restore (x0); \
105 cfi_restore (x1); \
106 ldp x2, x3, [sp, #32]; \
107 cfi_restore (x2); \
108 cfi_restore (x3); \
109 ldp x4, x5, [sp, #48]; \
110 cfi_restore (x4); \
111 cfi_restore (x5); \
112 ldp x6, x7, [sp, #64]; \
113 cfi_restore (x6); \
114 cfi_restore (x7); \
115 ldr x30, [sp], #80; \
116 cfi_adjust_cfa_offset (-80); \
117 cfi_restore (x30);
118#else
119# define CALL_MCOUNT /* Do nothing. */
120#endif
121
122/* Local label name for asm code. */
123#ifndef L
124# define L(name) .L##name
125#endif
126
127/* Load or store to/from a pc-relative EXPR into/from R, using T.
128 Note R and T are register numbers and not register names. */
129#define LDST_PCREL(OP, R, T, EXPR) \
130 adrp x##T, EXPR; \
131 OP PTR_REG (R), [x##T, #:lo12:EXPR]; \
132
133/* Load or store to/from a got-relative EXPR into/from R, using T.
134 Note R and T are register numbers and not register names. */
135#define LDST_GLOBAL(OP, R, T, EXPR) \
136 adrp x##T, :got:EXPR; \
137 ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
138 OP PTR_REG (R), [x##T];
139
140/* Load an immediate into R.
141 Note R is a register number and not a register name. */
142#ifdef __LP64__
143# define MOVL(R, NAME) \
144 movz PTR_REG (R), #:abs_g3:NAME; \
145 movk PTR_REG (R), #:abs_g2_nc:NAME; \
146 movk PTR_REG (R), #:abs_g1_nc:NAME; \
147 movk PTR_REG (R), #:abs_g0_nc:NAME;
148#else
149# define MOVL(R, NAME) \
150 movz PTR_REG (R), #:abs_g1:NAME; \
151 movk PTR_REG (R), #:abs_g0_nc:NAME;
152#endif
153
154/* Since C identifiers are not normally prefixed with an underscore
155 on this system, the asm identifier `syscall_error' intrudes on the
156 C name space. Make sure we use an innocuous name. */
157#define syscall_error __syscall_error
158#define mcount _mcount
159
160#endif /* __ASSEMBLER__ */
161
162#endif /* _AARCH64_SYSDEP_H */
libc/glibc/sysdeps/alpha/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* Alpha is little-endian. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __LITTLE_ENDIAN
libc/glibc/sysdeps/alpha/crti.S created+101
...@@ -0,0 +1,101 @@
1/* Special .init and .fini section support for Alpha.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI.
40
41 This differs from what would be generated for ordinary code in that
42 we save and restore the GP within the function. In order for linker
43 relaxation to work, the value in the GP register on exit from a function
44 must be valid for the function entry point. Normally, a function is
45 contained within one object file and this is not an issue, provided
46 that the function reloads the gp after making any function calls.
47 However, _init and _fini are constructed from pieces of many object
48 files, all of which may have different GP values. So we must reload
49 the GP value from crti.o in crtn.o. */
50
51#include <libc-symbols.h>
52#include <sysdep.h>
53
54#ifndef PREINIT_FUNCTION
55# define PREINIT_FUNCTION __gmon_start__
56#endif
57
58#ifndef PREINIT_FUNCTION_WEAK
59# define PREINIT_FUNCTION_WEAK 1
60#endif
61
62#if PREINIT_FUNCTION_WEAK
63 weak_extern (PREINIT_FUNCTION)
64#else
65 .hidden PREINIT_FUNCTION
66#endif
67
68 .section .init, "ax", @progbits
69 .globl _init
70 .hidden _init
71 .type _init, @function
72 .usepv _init, std
73_init:
74 ldgp $29, 0($27)
75 subq $30, 16, $30
76#if PREINIT_FUNCTION_WEAK
77 lda $27, PREINIT_FUNCTION
78#endif
79 stq $26, 0($30)
80 stq $29, 8($30)
81#if PREINIT_FUNCTION_WEAK
82 beq $27, 1f
83 jsr $26, ($27), PREINIT_FUNCTION
84 ldq $29, 8($30)
851:
86#else
87 bsr $26, PREINIT_FUNCTION !samegp
88#endif
89 .p2align 3
90
91 .section .fini, "ax", @progbits
92 .globl _fini
93 .hidden _fini
94 .type _fini,@function
95 .usepv _fini,std
96_fini:
97 ldgp $29, 0($27)
98 subq $30, 16, $30
99 stq $26, 0($30)
100 stq $29, 8($30)
101 .p2align 3
libc/glibc/sysdeps/alpha/crtn.S created+49
...@@ -0,0 +1,49 @@
1/* Special .init and .fini section support for Alpha.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init, "ax", @progbits
40 ldq $26, 0($30)
41 ldq $29, 8($30)
42 addq $30, 16, $30
43 ret
44
45 .section .fini, "ax", @progbits
46 ldq $26, 0($30)
47 ldq $29, 8($30)
48 addq $30, 16, $30
49 ret
libc/glibc/sysdeps/alpha/dl-dtprocnum.h created+3
...@@ -0,0 +1,3 @@
1/* Number of extra dynamic section entries for this architecture. By
2 default there are none. */
3#define DT_THISPROCNUM DT_ALPHA_NUM
libc/glibc/sysdeps/alpha/dl-sysdep.h created+23
...@@ -0,0 +1,23 @@
1/* System-specific settings for dynamic linker code. Alpha version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
libc/glibc/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h created+61
...@@ -0,0 +1,61 @@
1/* Machine-specific pthread type layouts. Alpha version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#define __SIZEOF_PTHREAD_ATTR_T 56
23#define __SIZEOF_PTHREAD_MUTEX_T 40
24#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
25#define __SIZEOF_PTHREAD_COND_T 48
26#define __SIZEOF_PTHREAD_CONDATTR_T 4
27#define __SIZEOF_PTHREAD_RWLOCK_T 56
28#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
29#define __SIZEOF_PTHREAD_BARRIER_T 32
30#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
31
32/* Definitions for internal mutex struct. */
33#define __PTHREAD_COMPAT_PADDING_MID
34#define __PTHREAD_COMPAT_PADDING_END
35#define __PTHREAD_MUTEX_LOCK_ELISION 0
36#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
37#define __PTHREAD_MUTEX_USE_UNION 0
38
39#define __LOCK_ALIGNMENT
40#define __ONCE_ALIGNMENT
41
42struct __pthread_rwlock_arch_t
43{
44 unsigned int __readers;
45 unsigned int __writers;
46 unsigned int __wrphase_futex;
47 unsigned int __writers_futex;
48 unsigned int __pad3;
49 unsigned int __pad4;
50 int __cur_writer;
51 int __shared;
52 unsigned long int __pad1;
53 unsigned long int __pad2;
54 /* FLAGS must stay at this position in the structure to maintain
55 binary compatibility. */
56 unsigned int __flags;
57};
58
59#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
60
61#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/alpha/start.S created+85
...@@ -0,0 +1,85 @@
1/* Startup code for Alpha/ELF.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Richard Henderson <rth@tamu.edu>
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library. If not, see
35 <http://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39 .text
40 .align 3
41 .globl _start
42 .ent _start, 0
43 .type _start,@function
44_start:
45 .frame $15, 0, $15
46 br gp, 1f
471: ldgp gp, 0(gp)
48 subq sp, 16, sp
49 mov 0, $15
50 .prologue 0
51
52 /* Load address of the user's main function. */
53 lda a0, main
54
55 ldl a1, 16(sp) /* get argc */
56 lda a2, 24(sp) /* get argv */
57
58 /* Load address of our own entry points to .fini and .init. */
59 lda a3, __libc_csu_init
60 lda a4, __libc_csu_fini
61
62 /* Store address of the shared library termination function. */
63 mov v0, a5
64
65 /* Provide the highest stack address to the user code. */
66 stq sp, 0(sp)
67
68 /* Call the user's main function, and exit with its value.
69 But let the libc call main. */
70 jsr ra, __libc_start_main
71
72 /* Die very horribly if exit returns. Call_pal hlt is callable from
73 kernel mode only; this will result in an illegal instruction trap. */
74 call_pal 0
75 .end _start
76
77/* For ECOFF backwards compatibility. */
78weak_alias (_start, __start)
79
80/* Define a symbol for the first piece of initialized data. */
81 .data
82 .globl __data_start
83__data_start:
84 .weak data_start
85 data_start = __data_start
libc/glibc/sysdeps/arm/bits/endian.h created+10
...@@ -0,0 +1,10 @@
1#ifndef _ENDIAN_H
2# error "Never use <bits/endian.h> directly; include <endian.h> instead."
3#endif
4
5/* ARM can be either big or little endian. */
6#ifdef __ARMEB__
7#define __BYTE_ORDER __BIG_ENDIAN
8#else
9#define __BYTE_ORDER __LITTLE_ENDIAN
10#endif
libc/glibc/sysdeps/arm/crti.S created+97
...@@ -0,0 +1,97 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41/* Always build .init and .fini sections in ARM mode. */
42#define NO_THUMB
43#include <libc-symbols.h>
44#include <sysdep.h>
45
46#ifndef PREINIT_FUNCTION
47# define PREINIT_FUNCTION __gmon_start__
48#endif
49
50#ifndef PREINIT_FUNCTION_WEAK
51# define PREINIT_FUNCTION_WEAK 1
52#endif
53
54#if PREINIT_FUNCTION_WEAK
55 weak_extern (PREINIT_FUNCTION)
56#else
57 .hidden PREINIT_FUNCTION
58#endif
59
60#if PREINIT_FUNCTION_WEAK
61 .p2align 2
62 .type call_weak_fn, %function
63call_weak_fn:
64 ldr r3, .LGOT
65 ldr r2, .LGOT+4
66.LPIC:
67 add r3, pc, r3
68 ldr r2, [r3, r2]
69 cmp r2, #0
70 bxeq lr
71 b PREINIT_FUNCTION
72 .p2align 2
73.LGOT:
74 .word _GLOBAL_OFFSET_TABLE_-(.LPIC+8)
75 .word PREINIT_FUNCTION(GOT)
76#endif
77
78 .section .init,"ax",%progbits
79 .p2align 2
80 .globl _init
81 .hidden _init
82 .type _init, %function
83_init:
84 push {r3, lr}
85#if PREINIT_FUNCTION_WEAK
86 bl call_weak_fn
87#else
88 bl PREINIT_FUNCTION
89#endif
90
91 .section .fini,"ax",%progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, %function
96_fini:
97 push {r3, lr}
libc/glibc/sysdeps/arm/crtn.S created+57
...@@ -0,0 +1,57 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* Always build .init and .fini sections in ARM mode. */
37#define NO_THUMB
38#include <sysdep.h>
39
40/* crtn.S puts function epilogues in the .init and .fini sections
41 corresponding to the prologues in crti.S. */
42
43 .section .init,"ax",%progbits
44#ifdef __ARM_ARCH_4T__
45 pop {r3, lr}
46 bx lr
47#else
48 pop {r3, pc}
49#endif
50
51 .section .fini,"ax",%progbits
52#ifdef __ARM_ARCH_4T__
53 pop {r3, lr}
54 bx lr
55#else
56 pop {r3, pc}
57#endif
libc/glibc/sysdeps/arm/dl-sysdep.h created+25
...@@ -0,0 +1,25 @@
1/* System-specific settings for dynamic linker code. Alpha version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
24
25#define DL_EXTERN_PROTECTED_DATA
libc/glibc/sysdeps/arm/nptl/bits/pthreadtypes-arch.h created+71
...@@ -0,0 +1,71 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <endian.h>
22
23#define __SIZEOF_PTHREAD_ATTR_T 36
24#define __SIZEOF_PTHREAD_MUTEX_T 24
25#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
26#define __SIZEOF_PTHREAD_COND_T 48
27#define __SIZEOF_PTHREAD_CONDATTR_T 4
28#define __SIZEOF_PTHREAD_RWLOCK_T 32
29#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
30#define __SIZEOF_PTHREAD_BARRIER_T 20
31#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
32
33/* Data structure for mutex handling. */
34#define __PTHREAD_COMPAT_PADDING_MID
35#define __PTHREAD_COMPAT_PADDING_END
36#define __PTHREAD_MUTEX_LOCK_ELISION 0
37#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
38#define __PTHREAD_MUTEX_USE_UNION 1
39
40#define __LOCK_ALIGNMENT
41#define __ONCE_ALIGNMENT
42
43struct __pthread_rwlock_arch_t
44{
45 unsigned int __readers;
46 unsigned int __writers;
47 unsigned int __wrphase_futex;
48 unsigned int __writers_futex;
49 unsigned int __pad3;
50 unsigned int __pad4;
51#if __BYTE_ORDER == __BIG_ENDIAN
52 unsigned char __pad1;
53 unsigned char __pad2;
54 unsigned char __shared;
55 /* FLAGS must stay at this position in the structure to maintain
56 binary compatibility. */
57 unsigned char __flags;
58#else
59 /* FLAGS must stay at this position in the structure to maintain
60 binary compatibility. */
61 unsigned char __flags;
62 unsigned char __shared;
63 unsigned char __pad1;
64 unsigned char __pad2;
65#endif
66 int __cur_writer;
67};
68
69#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
70
71#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/arm/start.S created+148
...@@ -0,0 +1,148 @@
1/* Startup code for ARM & ELF
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* This is the canonical entry point, usually the first thing in the text
37 segment.
38
39 Note that the code in the .init section has already been run.
40 This includes _init and _libc_init
41
42
43 At this entry point, most registers' values are unspecified, except:
44
45 a1 Contains a function pointer to be registered with `atexit'.
46 This is how the dynamic linker arranges to have DT_FINI
47 functions called for shared libraries that have been loaded
48 before this code runs.
49
50 sp The stack contains the arguments and environment:
51 0(sp) argc
52 4(sp) argv[0]
53 ...
54 (4*argc)(sp) NULL
55 (4*(argc+1))(sp) envp[0]
56 ...
57 NULL
58*/
59
60/* Tag_ABI_align8_preserved: This code preserves 8-byte
61 alignment in any callee. */
62 .eabi_attribute 25, 1
63/* Tag_ABI_align8_needed: This code may require 8-byte alignment from
64 the caller. */
65 .eabi_attribute 24, 1
66
67#if defined(__thumb2__)
68 .thumb
69 .syntax unified
70#endif
71
72 .text
73 .globl _start
74 .type _start,#function
75_start:
76 /* Protect against unhandled exceptions. */
77 .fnstart
78 /* Clear the frame pointer and link register since this is the outermost frame. */
79 mov fp, #0
80 mov lr, #0
81
82 /* Pop argc off the stack and save a pointer to argv */
83 pop { a2 }
84 mov a3, sp
85
86 /* Push stack limit */
87 push { a3 }
88
89 /* Push rtld_fini */
90 push { a1 }
91
92#ifdef PIC
93 ldr sl, .L_GOT
94 adr a4, .L_GOT
95 add sl, sl, a4
96
97 ldr ip, .L_GOT+4 /* __libc_csu_fini */
98 ldr ip, [sl, ip]
99
100 push { ip } /* Push __libc_csu_fini */
101
102 ldr a4, .L_GOT+8 /* __libc_csu_init */
103 ldr a4, [sl, a4]
104
105 ldr a1, .L_GOT+12 /* main */
106 ldr a1, [sl, a1]
107
108 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
109 /* Let the libc call main and exit with its return code. */
110 bl __libc_start_main(PLT)
111#else
112 /* Fetch address of __libc_csu_fini */
113 ldr ip, =__libc_csu_fini
114
115 /* Push __libc_csu_fini */
116 push { ip }
117
118 /* Set up the other arguments in registers */
119 ldr a1, =main
120 ldr a4, =__libc_csu_init
121
122 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
123 /* Let the libc call main and exit with its return code. */
124 bl __libc_start_main
125#endif
126
127 /* should never get here....*/
128 bl abort
129
130#ifdef PIC
131 .align 2
132.L_GOT:
133 .word _GLOBAL_OFFSET_TABLE_ - .L_GOT
134 .word __libc_csu_fini(GOT)
135 .word __libc_csu_init(GOT)
136 .word main(GOT)
137#endif
138
139 .cantunwind
140 .fnend
141
142/* Define a symbol for the first piece of initialized data. */
143 .data
144 .globl __data_start
145__data_start:
146 .long 0
147 .weak data_start
148 data_start = __data_start
libc/glibc/sysdeps/arm/sysdep.h created+339
...@@ -0,0 +1,339 @@
1/* Assembler macros for ARM.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20#include <features.h>
21
22#ifndef __ASSEMBLER__
23# include <stdint.h>
24#else
25# include <arm-features.h>
26#endif
27
28/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */
29#ifndef __ARM_ARCH
30# ifdef __ARM_ARCH_2__
31# define __ARM_ARCH 2
32# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
33# define __ARM_ARCH 3
34# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__)
35# define __ARM_ARCH 4
36# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \
37 || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \
38 || defined(__ARM_ARCH_5TEJ__)
39# define __ARM_ARCH 5
40# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
41 || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
42 || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)
43# define __ARM_ARCH 6
44# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
45 || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
46 || defined(__ARM_ARCH_7EM__)
47# define __ARM_ARCH 7
48# else
49# error unknown arm architecture
50# endif
51#endif
52
53#if __ARM_ARCH > 4 || defined (__ARM_ARCH_4T__)
54# define ARCH_HAS_BX
55#endif
56#if __ARM_ARCH > 4
57# define ARCH_HAS_BLX
58#endif
59#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
60# define ARCH_HAS_HARD_TP
61#endif
62#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6T2__)
63# define ARCH_HAS_T2
64#endif
65
66#ifdef __ASSEMBLER__
67
68/* Syntactic details of assembler. */
69
70#define ALIGNARG(log2) log2
71#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
72
73#define PLTJMP(_x) _x##(PLT)
74
75#ifdef ARCH_HAS_BX
76# define BX(R) bx R
77# define BXC(C, R) bx##C R
78# ifdef ARCH_HAS_BLX
79# define BLX(R) blx R
80# else
81# define BLX(R) mov lr, pc; bx R
82# endif
83#else
84# define BX(R) mov pc, R
85# define BXC(C, R) mov##C pc, R
86# define BLX(R) mov lr, pc; mov pc, R
87#endif
88
89#define DO_RET(R) BX(R)
90#define RETINSTR(C, R) BXC(C, R)
91
92/* Define an entry point visible from C. */
93#define ENTRY(name) \
94 .globl C_SYMBOL_NAME(name); \
95 .type C_SYMBOL_NAME(name),%function; \
96 .align ALIGNARG(4); \
97 C_LABEL(name) \
98 CFI_SECTIONS; \
99 cfi_startproc; \
100 CALL_MCOUNT
101
102#define CFI_SECTIONS \
103 .cfi_sections .debug_frame
104
105#undef END
106#define END(name) \
107 cfi_endproc; \
108 ASM_SIZE_DIRECTIVE(name)
109
110/* If compiled for profiling, call `mcount' at the start of each function. */
111#ifdef PROF
112/* Call __gnu_mcount_nc (GCC >= 4.4). */
113#define CALL_MCOUNT \
114 push {lr}; \
115 cfi_adjust_cfa_offset (4); \
116 cfi_rel_offset (lr, 0); \
117 bl PLTJMP(mcount); \
118 cfi_adjust_cfa_offset (-4); \
119 cfi_restore (lr)
120#else
121#define CALL_MCOUNT /* Do nothing. */
122#endif
123
124/* Since C identifiers are not normally prefixed with an underscore
125 on this system, the asm identifier `syscall_error' intrudes on the
126 C name space. Make sure we use an innocuous name. */
127#define syscall_error __syscall_error
128#define mcount __gnu_mcount_nc
129
130/* Tag_ABI_align8_preserved: This code preserves 8-byte
131 alignment in any callee. */
132 .eabi_attribute 25, 1
133/* Tag_ABI_align8_needed: This code may require 8-byte alignment from
134 the caller. */
135 .eabi_attribute 24, 1
136
137/* The thumb2 encoding is reasonably complete. Unless suppressed, use it. */
138 .syntax unified
139# if defined(__thumb2__) && !defined(NO_THUMB)
140 .thumb
141#else
142# undef __thumb__
143# undef __thumb2__
144 .arm
145# endif
146
147/* Load or store to/from address X + Y into/from R, (maybe) using T.
148 X or Y can use T freely; T can be R if OP is a load. The first
149 version eschews the two-register addressing mode, while the
150 second version uses it. */
151# define LDST_INDEXED_NOINDEX(OP, R, T, X, Y) \
152 add T, X, Y; \
153 OP R, [T]
154# define LDST_INDEXED_INDEX(OP, R, X, Y) \
155 OP R, [X, Y]
156
157# ifdef ARM_NO_INDEX_REGISTER
158/* We're never using the two-register addressing mode, so this
159 always uses an intermediate add. */
160# define LDST_INDEXED(OP, R, T, X, Y) LDST_INDEXED_NOINDEX (OP, R, T, X, Y)
161# define LDST_PC_INDEXED(OP, R, T, X) LDST_INDEXED_NOINDEX (OP, R, T, pc, X)
162# else
163/* The two-register addressing mode is OK, except on Thumb with pc. */
164# define LDST_INDEXED(OP, R, T, X, Y) LDST_INDEXED_INDEX (OP, R, X, Y)
165# ifdef __thumb2__
166# define LDST_PC_INDEXED(OP, R, T, X) LDST_INDEXED_NOINDEX (OP, R, T, pc, X)
167# else
168# define LDST_PC_INDEXED(OP, R, T, X) LDST_INDEXED_INDEX (OP, R, pc, X)
169# endif
170# endif
171
172/* Load or store to/from a pc-relative EXPR into/from R, using T. */
173# ifdef __thumb2__
174# define LDST_PCREL(OP, R, T, EXPR) \
175 ldr T, 98f; \
176 .subsection 2; \
17798: .word EXPR - 99f - PC_OFS; \
178 .previous; \
17999: add T, T, pc; \
180 OP R, [T]
181# elif defined (ARCH_HAS_T2) && ARM_PCREL_MOVW_OK
182# define LDST_PCREL(OP, R, T, EXPR) \
183 movw T, #:lower16:EXPR - 99f - PC_OFS; \
184 movt T, #:upper16:EXPR - 99f - PC_OFS; \
18599: LDST_PC_INDEXED (OP, R, T, T)
186# else
187# define LDST_PCREL(OP, R, T, EXPR) \
188 ldr T, 98f; \
189 .subsection 2; \
19098: .word EXPR - 99f - PC_OFS; \
191 .previous; \
19299: OP R, [pc, T]
193# endif
194
195/* Load from a global SYMBOL + CONSTANT into R, using T. */
196# if defined (ARCH_HAS_T2) && !defined (PIC)
197# define LDR_GLOBAL(R, T, SYMBOL, CONSTANT) \
198 movw T, #:lower16:SYMBOL; \
199 movt T, #:upper16:SYMBOL; \
200 ldr R, [T, $CONSTANT]
201# elif defined (ARCH_HAS_T2) && defined (PIC) && ARM_PCREL_MOVW_OK
202# define LDR_GLOBAL(R, T, SYMBOL, CONSTANT) \
203 movw R, #:lower16:_GLOBAL_OFFSET_TABLE_ - 97f - PC_OFS; \
204 movw T, #:lower16:99f - 98f - PC_OFS; \
205 movt R, #:upper16:_GLOBAL_OFFSET_TABLE_ - 97f - PC_OFS; \
206 movt T, #:upper16:99f - 98f - PC_OFS; \
207 .pushsection .rodata.cst4, "aM", %progbits, 4; \
208 .balign 4; \
20999: .word SYMBOL##(GOT); \
210 .popsection; \
21197: add R, R, pc; \
21298: LDST_PC_INDEXED (ldr, T, T, T); \
213 LDST_INDEXED (ldr, R, T, R, T); \
214 ldr R, [R, $CONSTANT]
215# else
216# define LDR_GLOBAL(R, T, SYMBOL, CONSTANT) \
217 ldr T, 99f; \
218 ldr R, 100f; \
21998: add T, T, pc; \
220 ldr T, [T, R]; \
221 .subsection 2; \
22299: .word _GLOBAL_OFFSET_TABLE_ - 98b - PC_OFS; \
223100: .word SYMBOL##(GOT); \
224 .previous; \
225 ldr R, [T, $CONSTANT]
226# endif
227
228/* This is the same as LDR_GLOBAL, but for a SYMBOL that is known to
229 be in the same linked object (as for one with hidden visibility).
230 We can avoid the GOT indirection in the PIC case. For the pure
231 static case, LDR_GLOBAL is already optimal. */
232# ifdef PIC
233# define LDR_HIDDEN(R, T, SYMBOL, CONSTANT) \
234 LDST_PCREL (ldr, R, T, SYMBOL + CONSTANT)
235# else
236# define LDR_HIDDEN(R, T, SYMBOL, CONSTANT) \
237 LDR_GLOBAL (R, T, SYMBOL, CONSTANT)
238# endif
239
240/* Cope with negative memory offsets, which thumb can't encode.
241 Use NEGOFF_ADJ_BASE to (conditionally) alter the base register,
242 and then NEGOFF_OFF1 to use 0 for thumb and the offset for arm,
243 or NEGOFF_OFF2 to use A-B for thumb and A for arm. */
244# ifdef __thumb2__
245# define NEGOFF_ADJ_BASE(R, OFF) add R, R, $OFF
246# define NEGOFF_ADJ_BASE2(D, S, OFF) add D, S, $OFF
247# define NEGOFF_OFF1(R, OFF) [R]
248# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $((OFFA) - (OFFB))]
249# else
250# define NEGOFF_ADJ_BASE(R, OFF)
251# define NEGOFF_ADJ_BASE2(D, S, OFF) mov D, S
252# define NEGOFF_OFF1(R, OFF) [R, $OFF]
253# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $OFFA]
254# endif
255
256/* Helper to get the TLS base pointer. The interface is that TMP is a
257 register that may be used to hold the LR, if necessary. TMP may be
258 LR itself to indicate that LR need not be saved. The base pointer
259 is returned in R0. Only R0 and TMP are modified. */
260
261# ifdef ARCH_HAS_HARD_TP
262/* If the cpu has cp15 available, use it. */
263# define GET_TLS(TMP) mrc p15, 0, r0, c13, c0, 3
264# else
265/* At this generic level we have no tricks to pull. Call the ABI routine. */
266# define GET_TLS(TMP) \
267 push { r1, r2, r3, lr }; \
268 cfi_remember_state; \
269 cfi_adjust_cfa_offset (16); \
270 cfi_rel_offset (r1, 0); \
271 cfi_rel_offset (r2, 4); \
272 cfi_rel_offset (r3, 8); \
273 cfi_rel_offset (lr, 12); \
274 bl __aeabi_read_tp; \
275 pop { r1, r2, r3, lr }; \
276 cfi_restore_state
277# endif /* ARCH_HAS_HARD_TP */
278
279/* These are the directives used for EABI unwind info.
280 Wrap them in macros so another configuration's sysdep.h
281 file can define them away if it doesn't use EABI unwind info. */
282# define eabi_fnstart .fnstart
283# define eabi_fnend .fnend
284# define eabi_save(...) .save __VA_ARGS__
285# define eabi_cantunwind .cantunwind
286# define eabi_pad(n) .pad n
287
288#endif /* __ASSEMBLER__ */
289
290/* This number is the offset from the pc at the current location. */
291#ifdef __thumb__
292# define PC_OFS 4
293#else
294# define PC_OFS 8
295#endif
296
297/* Pointer mangling support. */
298#if (IS_IN (rtld) || \
299 (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
300# ifdef __ASSEMBLER__
301# define PTR_MANGLE_LOAD(guard, tmp) \
302 LDR_HIDDEN (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local), 0)
303# define PTR_MANGLE(dst, src, guard, tmp) \
304 PTR_MANGLE_LOAD(guard, tmp); \
305 PTR_MANGLE2(dst, src, guard)
306/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
307# define PTR_MANGLE2(dst, src, guard) \
308 eor dst, src, guard
309# define PTR_DEMANGLE(dst, src, guard, tmp) \
310 PTR_MANGLE (dst, src, guard, tmp)
311# define PTR_DEMANGLE2(dst, src, guard) \
312 PTR_MANGLE2 (dst, src, guard)
313# else
314extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
315# define PTR_MANGLE(var) \
316 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
317# define PTR_DEMANGLE(var) PTR_MANGLE (var)
318# endif
319#else
320# ifdef __ASSEMBLER__
321# define PTR_MANGLE_LOAD(guard, tmp) \
322 LDR_GLOBAL (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard), 0);
323# define PTR_MANGLE(dst, src, guard, tmp) \
324 PTR_MANGLE_LOAD(guard, tmp); \
325 PTR_MANGLE2(dst, src, guard)
326/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
327# define PTR_MANGLE2(dst, src, guard) \
328 eor dst, src, guard
329# define PTR_DEMANGLE(dst, src, guard, tmp) \
330 PTR_MANGLE (dst, src, guard, tmp)
331# define PTR_DEMANGLE2(dst, src, guard) \
332 PTR_MANGLE2 (dst, src, guard)
333# else
334extern uintptr_t __pointer_chk_guard attribute_relro;
335# define PTR_MANGLE(var) \
336 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
337# define PTR_DEMANGLE(var) PTR_MANGLE (var)
338# endif
339#endif
libc/glibc/sysdeps/csky/abiv2/start.S created+108
...@@ -0,0 +1,108 @@
1/* Startup code compliant to the ELF C-SKY ABIV2.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* We need to call:
37 __libc_start_main (int (*main) (int, char **, char **), int argc,
38 char **argv, void (*init) (void), void (*fini) (void),
39 void (*rtld_fini) (void), void *stack_end)
40 */
41
42#include <sysdep.h>
43
44 .text
45 .globl _start;
46 .type _start,@function;
47 .align 4;
48_start:
49 subi sp, 8
50 /* Clear the link register since this is the outermost frame. */
51 movi lr, 0
52 /* Pop argc off the stack and save a pointer to argv. */
53 ldw a1, (sp, 8) /* Init argc for __libc_start_main. */
54 addi a2, sp, 12 /* Init argv for __libc_start_main. */
55
56 /* Push stack limit. */
57 stw a2, (sp, 8)
58 /* Push rtld_fini. */
59 stw a0, (sp, 4)
60
61#ifdef SHARED
62 grs t0, .Lgetpc
63.Lgetpc:
64 lrw gb, .Lgetpc@GOTPC
65 addu gb, t0
66 lrw a3, __libc_csu_fini@GOT
67 ldr.w a3, (gb, a3 << 0)
68 stw a3, (sp, 0)
69
70 lrw a3, __libc_csu_init@GOT
71 addu a3, gb
72 ldw a3, (a3, 0)
73
74 lrw t0, main@GOT
75 addu t0, gb
76 ldw a0, (t0, 0)
77 lrw t1, __libc_start_main@PLT
78 ldr.w t1, (gb, t1 << 0)
79 jsr t1
80
81 lrw t1, abort@PLT
82 ldr.w t1, (gb, t1 << 0)
83 jsr t1
84#else
85 /* Fetch address of __libc_csu_fini. */
86 lrw a0, __libc_csu_fini
87 /* Push __libc_csu_fini */
88 stw a0, (sp, 0)
89
90 /* Set up the other arguments in registers. */
91 lrw a0, main
92 lrw a3, __libc_csu_init
93 /* Let the libc call main and exit with its return code. */
94 jsri __libc_start_main
95
96 /* Should never get here. */
97 jsri abort
98#endif /* !SHARED */
99 .size _start,.-_start
100
101
102 /* Define a symbol for the first piece of initialized data. */
103 .data
104 .globl __data_start
105__data_start:
106 .long 0
107 .weak data_start
108 data_start = __data_start
libc/glibc/sysdeps/csky/bits/endian.h created+9
...@@ -0,0 +1,9 @@
1#ifndef _ENDIAN_H
2# error "Never use <bits/endian.h> directly; include <endian.h> instead."
3#endif
4
5#ifdef __CSKYBE__
6# error "Big endian not supported for C-SKY."
7#else
8# define __BYTE_ORDER __LITTLE_ENDIAN
9#endif
libc/glibc/sysdeps/csky/dl-sysdep.h created+23
...@@ -0,0 +1,23 @@
1/* System-specific settings for dynamic linker code. C-SKY version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
libc/glibc/sysdeps/csky/nptl/bits/pthreadtypes-arch.h created+70
...@@ -0,0 +1,70 @@
1/* Machine-specific pthread type layouts. C-SKY version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <endian.h>
23
24#define __SIZEOF_PTHREAD_ATTR_T 36
25#define __SIZEOF_PTHREAD_MUTEX_T 24
26#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
27#define __SIZEOF_PTHREAD_COND_T 48
28#define __SIZEOF_PTHREAD_CONDATTR_T 4
29#define __SIZEOF_PTHREAD_RWLOCK_T 32
30#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
31#define __SIZEOF_PTHREAD_BARRIER_T 20
32#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
33
34/* Data structure for mutex handling. */
35#define __PTHREAD_COMPAT_PADDING_MID
36#define __PTHREAD_COMPAT_PADDING_END
37#define __PTHREAD_MUTEX_LOCK_ELISION 0
38#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
39#define __PTHREAD_MUTEX_USE_UNION 1
40
41#define __LOCK_ALIGNMENT
42#define __ONCE_ALIGNMENT
43
44/* Paddings in this structure are not strictly necessary on C-SKY.
45 They are left for extensibility as most other architecture do so. */
46struct __pthread_rwlock_arch_t
47{
48 unsigned int __readers;
49 unsigned int __writers;
50 unsigned int __wrphase_futex;
51 unsigned int __writers_futex;
52 unsigned int __pad3;
53 unsigned int __pad4;
54#if __BYTE_ORDER == __BIG_ENDIAN
55 unsigned char __pad1;
56 unsigned char __pad2;
57 unsigned char __shared;
58 unsigned char __flags;
59#else
60 unsigned char __flags;
61 unsigned char __shared;
62 unsigned char __pad1;
63 unsigned char __pad2;
64#endif
65 int __cur_writer;
66};
67
68#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
69
70#endif
libc/glibc/sysdeps/csky/sysdep.h created+84
...@@ -0,0 +1,84 @@
1/* Assembler macros for C-SKY.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20#include <features.h>
21
22#ifdef __ASSEMBLER__
23
24# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
25
26/* Define an entry point visible from C. */
27# define ENTRY(name) \
28 .globl name; \
29 .type name,@function; \
30 .align 4; \
31 name##:; \
32 cfi_startproc; \
33 CALL_MCOUNT
34
35# undef END
36# define END(name) \
37 cfi_endproc; \
38 ASM_SIZE_DIRECTIVE(name)
39
40/* If compiled for profiling, call `mcount' at the start of each function. */
41# ifdef PROF
42# ifdef __PIC__
43# define CALL_MCOUNT \
44 subi sp, 4; \
45 stw lr, (sp, 0); \
46 grs t0, .Lgetpc; \
47.Lgetpc: \
48 lrw gb, .Lgetpc@GOTPC; \
49 addu gb, t0; \
50 lrw t1, _mcount@PLT; \
51 ldr.w t0, (gb, t1 << 0); \
52 jmp t0;
53# else
54# define CALL_MCOUNT \
55 subi sp, 4; \
56 stw lr, (sp, 0); \
57 jbsr _mcount;
58# endif
59# else
60# define CALL_MCOUNT /* Do nothing. */
61# endif
62
63# if defined (__CK860__)
64/* Instruction fetch will be faster when the label is 16 bytes aligned.
65 Filling with nop instruction to avoid extra jump. */
66# define LABLE_ALIGN \
67 .balignw 16, 0x6c03
68
69# define PRE_BNEZAD(R)
70
71# define BNEZAD(R, L) \
72 bnezad R, L
73# else
74# define LABLE_ALIGN \
75 .balignw 8, 0x6c03
76
77# define PRE_BNEZAD(R) \
78 subi R, 1
79
80# define BNEZAD(R, L) \
81 bnez R, L
82# endif
83
84#endif
libc/glibc/sysdeps/generic/allocalim.h deleted-4
...@@ -1,4 +0,0 @@
1extern inline int __libc_use_alloca (size_t size)
2{
3 return size <= __MAX_ALLOCA_CUTOFF;
4}
libc/glibc/sysdeps/generic/dl-sysdep.h created+34
...@@ -0,0 +1,34 @@
1/* System-specific settings for dynamic linker code. Generic version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* No multiple inclusion protection need here because it's just macros.
20 We don't want to use _DL_SYSDEP_H in case we are #include_next'd. */
21
22/* This macro must be defined to either 0 or 1.
23
24 If 1, then an errno global variable hidden in ld.so will work right with
25 all the errno-using libc code compiled for ld.so, and there is never a
26 need to share the errno location with libc. This is appropriate only if
27 all the libc functions that ld.so uses are called without PLT and always
28 get the versions linked into ld.so rather than the libc ones. */
29
30#if IS_IN (rtld)
31# define RTLD_PRIVATE_ERRNO 1
32#else
33# define RTLD_PRIVATE_ERRNO 0
34#endif
libc/glibc/sysdeps/generic/stackinfo.h deleted-20
...@@ -1,20 +0,0 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* This file contains a bit of information about the stack allocation
19 of the processor. Since there is no general truth we can't say
20 anything here. */
libc/glibc/sysdeps/generic/sys/syscall.h created+2
...@@ -0,0 +1,2 @@
1/* For Unix-like systems, this file should contain definitions
2 of macros SYS_call for each system call, giving the call numbers. */
libc/glibc/sysdeps/generic/tls.h created+80
...@@ -0,0 +1,80 @@
1/* Definition for thread-local data handling. Generic version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* An architecture-specific version of this file has to defined a
20 number of symbols:
21
22 TLS_TCB_AT_TP or TLS_DTV_AT_TP
23
24 The presence of one of these symbols signals which variant of
25 the TLS ABI is used. There are in the moment two variants
26 available:
27
28 * the thread pointer points to a thread control block
29
30 * the thread pointer points to the dynamic thread vector
31
32
33 TLS_TCB_SIZE
34
35 This is the size of the thread control block structure. How
36 this is actually defined depends on the ABI. The thread control
37 block could be internal descriptor of the thread library or
38 just a data structure which allows finding the DTV.
39
40 TLS_INIT_TCB_SIZE
41
42 Similarly, but this value is only used at startup and in the
43 dynamic linker itself. There are no threads in use at that time.
44
45
46 TLS_TCB_ALIGN
47
48 Alignment requirements for the TCB structure.
49
50 TLS_INIT_TCB_ALIGN
51
52 Similarly, but for the structure used at startup time.
53
54
55 INSTALL_DTV(tcb, init_dtv)
56
57 This macro must install the given initial DTV into the thread control
58 block TCB. The normal runtime functionality must then be able to
59 use the value.
60
61
62 TLS_INIT_TP(tcb)
63
64 This macro must initialize the thread pointer to enable normal TLS
65 operation. The parameter is a pointer to the thread control block.
66 ld.so calls this macro once.
67
68
69 THREAD_DTV()
70
71 This macro returns the address of the DTV of the current thread.
72 This normally is done using the thread register which points
73 to the dtv or the TCB (from which the DTV can found).
74
75
76 THREAD_GSCOPE_IN_TCB
77
78 This should be set to 1 if the global scope flag is stored within the TCB.
79 When set to 0, GL(_dl_thread_gscope_count) will be defined to store it.
80 */
libc/glibc/sysdeps/hppa/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* hppa1.1 big-endian. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __BIG_ENDIAN
libc/glibc/sysdeps/hppa/crti.S created+162
...@@ -0,0 +1,162 @@
1/* Special .init and .fini section support for HPPA
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58
59/* If we have working .init_array support, we want to keep the .init
60 section empty (apart from the mandatory prologue/epilogue. This
61 ensures that the default unwind conventions (return-pointer in b0,
62 frame state in ar.pfs, etc.) will do the Right Thing. To ensure
63 an empty .init section, we register gmon_initializer() via the
64 .init_array.
65
66 --davidm 02/10/29 */
67
68#if PREINIT_FUNCTION_WEAK
69/* This blob of assembly code is one simple C function:
70
71static void
72__attribute__ ((used))
73gmon_initializer (void)
74{
75 extern void weak_function __gmon_start__ (void);
76
77 if (__gmon_start__)
78 (*__gmon_start__)();
79}
80
81In a final executable, PLABEL32 relocations for function pointers are
82resolved at link time. Typically, binutils/ld resolves __gmon_start__
83using an external shared library. __gmon_start__ is always called if
84it is found at link time. If __gmon_start__ is not found at runtime
85due to a library update, then the function pointer will point at a null
86function descriptor and calling it will cause a segmentation fault.
87So, we call __canonicalize_funcptr_for_compare to obtain the canonicalized
88address of __gmon_start__ and skip calling __gmon_start__ if it is zero.
89
90 */
91 .type __canonicalize_funcptr_for_compare,@function
92 .type $$dyncall,@function
93
94 .section .data.rel.ro,"aw",@progbits
95 .align 4
96.LC0:
97 .type __gmon_start__,@function
98 .word P%__gmon_start__
99
100 .text
101 .align 4
102 .type gmon_initializer,@function
103gmon_initializer:
104 .PROC
105 .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=4
106 .ENTRY
107 stw %r2,-20(%r30)
108 stwm %r4,64(%r30)
109 stw %r3,-60(%r30)
110 addil LT'.LC0,%r19
111 ldw RT'.LC0(%r1),%r28
112 ldw 0(%r28),%r3
113 comib,= 0,%r3,1f
114 copy %r19,%r4
115 stw %r19,-32(%r30)
116 bl __canonicalize_funcptr_for_compare,%r2
117 copy %r3,%r26
118 comib,= 0,%r28,1f
119 copy %r4,%r19
120 copy %r3,%r22
121 .CALL ARGW0=GR
122 bl $$dyncall,%r31
123 copy %r31,%r2
1241:
125 ldw -84(%r30),%r2
126 ldw -60(%r30),%r3
127 bv %r0(%r2)
128 ldwm -64(%r30),%r4
129 .EXIT
130 .PROCEND
131 .size gmon_initializer, .-gmon_initializer
132
133# undef PREINIT_FUNCTION
134# define PREINIT_FUNCTION gmon_initializer
135#endif
136
137 .section .init_array, "aw"
138 .word P% PREINIT_FUNCTION
139
140
141/* _init prologue. */
142 .section .init, "ax", %progbits
143 .align 4
144 .globl _init
145 .hidden _init
146 .type _init,@function
147_init:
148 stw %rp,-20(%sp)
149 stwm %r4,64(%sp)
150 stw %r19,-32(%sp)
151
152/* _fini prologue. */
153 .section .fini,"ax",%progbits
154 .align 4
155 .globl _fini
156 .hidden _fini
157 .type _fini,@function
158_fini:
159 stw %rp,-20(%sp)
160 stwm %r4,64(%sp)
161 stw %r19,-32(%sp)
162 copy %r19,%r4
libc/glibc/sysdeps/hppa/crtn.S created+66
...@@ -0,0 +1,66 @@
1/* Special .init and .fini section support for HPPA
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38/* crtn.S puts function epilogues in the .init and .fini sections
39 corresponding to the prologues in crti.S. */
40
41 .section .init, "ax", @progbits
42 ldw -84(%sp),%rp
43 copy %r4,%r19
44 bv %r0(%rp)
45_end_init:
46 ldwm -64(%sp),%r4
47
48/* Our very own unwind info, because the assembler can't handle
49 functions split into two or more pieces. */
50 .section .PARISC.unwind
51 .extern _init
52 .word _init, _end_init
53 .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
54
55/* Here is the tail end of _fini. */
56 .section .fini, "ax", @progbits
57 ldw -84(%sp),%rp
58 copy %r4,%r19
59 bv %r0(%rp)
60_end_fini:
61 ldwm -64(%sp),%r4
62
63 .section .PARISC.unwind
64 .extern _fini
65 .word _fini, _end_fini
66 .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
libc/glibc/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h created+91
...@@ -0,0 +1,91 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21/* Linuxthread type sizes (bytes):
22 sizeof(pthread_attr_t) = 0x24 (36)
23 sizeof(pthread_barrier_t) = 0x30 (48)
24 sizeof(pthread_barrierattr_t) = 0x4 (4)
25 sizeof(pthread_cond_t) = 0x30 (48)
26 sizeof(pthread_condattr_t) = 0x4 (4)
27 sizeof(pthread_mutex_t) = 0x30 (48)
28 sizeof(pthread_mutexattr_t) = 0x4 (4)
29 sizeof(pthread_rwlock_t) = 0x40 (64)
30 sizeof(pthread_rwlockattr_t) = 0x8 (8)
31 sizeof(pthread_spinlock_t) = 0x10 (16) */
32
33#define __SIZEOF_PTHREAD_ATTR_T 36
34#define __SIZEOF_PTHREAD_MUTEX_T 48
35#define __SIZEOF_PTHREAD_BARRIER_T 48
36#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
37#define __SIZEOF_PTHREAD_COND_T 48
38#define __SIZEOF_PTHREAD_CONDATTR_T 4
39#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
40#define __SIZEOF_PTHREAD_RWLOCK_T 64
41#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
42
43/* The old 4-word 16-byte aligned lock. This is initalized
44 to all ones by the Linuxthreads PTHREAD_MUTEX_INITIALIZER.
45 Unused in NPTL. */
46#define __PTHREAD_COMPAT_PADDING_MID int __compat_padding[4];
47/* Two more words are left before the NPTL
48 pthread_mutex_t is larger than Linuxthreads. */
49#define __PTHREAD_COMPAT_PADDING_END int __reserved[2];
50#define __PTHREAD_MUTEX_LOCK_ELISION 0
51#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
52#define __PTHREAD_MUTEX_USE_UNION 1
53
54#define __LOCK_ALIGNMENT __attribute__ ((__aligned__(16)))
55#define __ONCE_ALIGNMENT
56
57struct __pthread_rwlock_arch_t
58{
59 /* In the old Linuxthreads pthread_rwlock_t, this is the
60 start of the 4-word 16-byte aligned lock structure. The
61 next four words are all set to 1 by the Linuxthreads
62 PTHREAD_RWLOCK_INITIALIZER. We ignore them in NPTL. */
63 int __compat_padding[4] __attribute__ ((__aligned__(16)));
64 unsigned int __readers;
65 unsigned int __writers;
66 unsigned int __wrphase_futex;
67 unsigned int __writers_futex;
68 unsigned int __pad3;
69 unsigned int __pad4;
70 int __cur_writer;
71 /* An unused word, reserved for future use. It was added
72 to maintain the location of the flags from the Linuxthreads
73 layout of this structure. */
74 int __reserved1;
75 /* FLAGS must stay at this position in the structure to maintain
76 binary compatibility. */
77 unsigned char __pad2;
78 unsigned char __pad1;
79 unsigned char __shared;
80 unsigned char __flags;
81 /* The NPTL pthread_rwlock_t is 4 words smaller than the
82 Linuxthreads version. One word is in the middle of the
83 structure, the other three are at the end. */
84 int __reserved2;
85 int __reserved3;
86 int __reserved4;
87};
88
89#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
90
91#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/hppa/start.S created+152
...@@ -0,0 +1,152 @@
1/* ELF startup code for HPPA.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36 .import main, code
37 .import $global$, data
38 .import __libc_start_main, code
39 .import __libc_csu_fini, code
40 .import __libc_csu_init, code
41
42 /* Have the linker create plabel words so we get PLABEL32
43 relocs and not 21/14. The use of 21/14 relocs is only
44 supported in the latest dynamic linker. */
45#ifdef PIC
46 .section .data.rel.ro,"aw",@progbits
47#else
48 .section .rodata,"a",@progbits
49#endif
50 .align 4
51.Lpmain:
52 .word P%main
53.Lp__libc_start_main:
54 .word P%__libc_start_main
55.Lp__libc_csu_fini:
56 .word P%__libc_csu_fini
57.Lp__libc_csu_init:
58 .word P%__libc_csu_init
59
60 .text
61 .align 4
62 .globl _start
63 .export _start, ENTRY
64 .type _start,@function
65_start:
66 /* At entry to the function we have:
67
68 r26 - Unused
69 r25 - argc
70 r24 - argv
71 r23 - False _dl_fini plabel address
72
73 This function is called from the lower half of RTLD_START.
74
75 The call to __libc_start_main expects:
76
77 1. r26 - Application main
78 2. r25 - argc
79 3. r24 - argv
80 4. r23 - __libc_csu_init
81 5. sp-52 - __libc_csu_fini
82 6. sp-56 - rtld_fini
83 7. sp-60 - stackend */
84
85 .proc
86 .callinfo
87 /* Clear previous-sp. */
88 stw %r0, -4(%sp)
89 /* Setup the stack and frame. */
90 stw %rp, -20(%sp)
91 ldo 64(%sp), %sp
92 stw %sp, -4(%sp)
93 stw %r19, -32(%sp)
94
95 /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
96 /* void (*rtld_fini) (void) (6th argument) */
97 stw %r23, -56(%sp)
98
99 /* Need to setup 1, 4, 5, and 7th arguments */
100
101#ifdef PIC
102 /* Load $global$ address into %dp */
103 bl .+8, %dp
104 addil L'$global$-$PIC_pcrel$0+1, %dp
105 ldo R'$global$-$PIC_pcrel$0+5(%r1), %dp
106
107 /* load main (1st argument) */
108 addil LT'.Lpmain, %r19
109 ldw RT'.Lpmain(%r1), %r26
110 ldw 0(%r26),%r26
111 /* void (*init) (void) (4th argument) */
112 addil LT'.Lp__libc_csu_init, %r19
113 ldw RT'.Lp__libc_csu_init(%r1), %r23
114 ldw 0(%r23), %r23
115 /* void (*fini) (void) (5th argument) */
116 addil LT'.Lp__libc_csu_fini, %r19
117 ldw RT'.Lp__libc_csu_fini(%r1), %r22
118 ldw 0(%r22), %r22
119#else
120 /* Load $global$ address into %dp */
121 ldil L%$global$, %dp
122 ldo R%$global$(%dp), %dp
123
124 /* load main (1st argument) */
125 ldil LR'.Lpmain, %r26
126 ldw RR'.Lpmain(%r26), %r26
127 /* void (*init) (void) (4th argument) */
128 ldil LR'.Lp__libc_csu_init, %r23
129 ldw RR'.Lp__libc_csu_init(%r23), %r23
130 /* void (*fini) (void) (5th argument) */
131 ldil LR'.Lp__libc_csu_fini, %r22
132 ldw RR'.Lp__libc_csu_fini(%r22), %r22
133#endif
134 /* Store 5th argument */
135 stw %r22, -52(%sp)
136 /* void *stack_end (7th argument) */
137 stw %sp, -60(%sp)
138 bl __libc_start_main,%r2
139 nop
140 /* die horribly if it returned (it shouldn't) */
141 iitlbp %r0,(%sr0,%r0)
142 nop
143
144 .procend
145
146/* Define a symbol for the first piece of initialized data. */
147 .data
148 .globl __data_start
149__data_start:
150 .long 0
151 .weak data_start
152 data_start = __data_start
libc/glibc/sysdeps/hppa/sysdep.h created+74
...@@ -0,0 +1,74 @@
1/* Assembler macros for HP/PA.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <sysdeps/generic/sysdep.h>
21
22#undef ASM_LINE_SEP
23#define ASM_LINE_SEP !
24
25#ifdef __ASSEMBLER__
26
27/* Syntactic details of assembler. */
28
29#define ALIGNARG(log2) log2
30
31
32/* Define an entry point visible from C.
33
34 There is currently a bug in gdb which prevents us from specifying
35 incomplete stabs information. Fake some entries here which specify
36 the current source file. */
37#define ENTRY(name) \
38 .SPACE $TEXT$ ASM_LINE_SEP \
39 .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY ASM_LINE_SEP \
40 .align ALIGNARG(4) ASM_LINE_SEP \
41 .NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY ASM_LINE_SEP \
42 .EXPORT C_SYMBOL_NAME(name),ENTRY,PRIV_LEV=3,ARGW0=GR,RTNVAL=GR ASM_LINE_SEP\
43 C_LABEL(name) \
44 CALL_MCOUNT
45
46#undef END
47#define END(name) \
48 .PROCEND
49
50/* GCC does everything for us. */
51#ifdef PROF
52#define CALL_MCOUNT
53#else
54#define CALL_MCOUNT /* Do nothing. */
55#endif
56
57#define PSEUDO(name, syscall_name, args) \
58 ENTRY (name) \
59 DO_CALL (syscall_name, args)
60
61#undef PSEUDO_END
62#define PSEUDO_END(name) \
63 END (name)
64
65#undef JUMPTARGET
66#define JUMPTARGET(name) name
67#define SYSCALL_PIC_SETUP /* Nothing. */
68
69/* Local label name for asm code. */
70#ifndef L
71#define L(name) name
72#endif
73
74#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/htl/bits/pthread.h created+36
...@@ -0,0 +1,36 @@
1/* Pthread data structures. Generic version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREAD_H
20#define _BITS_PTHREAD_H 1
21
22typedef int __pthread_t;
23
24/* Return true if __T1 and __T2 both name the same thread. Otherwise,
25 false. */
26extern int __pthread_equal (__pthread_t __t1, __pthread_t __t2);
27
28#ifdef __USE_EXTERN_INLINES
29__extern_inline int
30__pthread_equal (__pthread_t __t1, __pthread_t __t2)
31{
32 return __t1 == __t2;
33}
34#endif
35
36#endif /* bits/pthread.h */
libc/glibc/sysdeps/htl/bits/thread-shared-types.h created+24
...@@ -0,0 +1,24 @@
1/* Common threading primitives definitions for both POSIX and C11.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _THREAD_SHARED_TYPES_H
20#define _THREAD_SHARED_TYPES_H 1
21
22#include <bits/pthreadtypes-arch.h>
23
24#endif /* _THREAD_SHARED_TYPES_H */
libc/glibc/sysdeps/htl/libc-lockP.h created+180
...@@ -0,0 +1,180 @@
1/* Private libc-internal interface for mutex locks.
2 Copyright (C) 2015-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_LIBC_LOCKP_H
20#define _BITS_LIBC_LOCKP_H 1
21
22#include <pthread.h>
23#include <pthread-functions.h>
24
25/* Type for key to thread-specific data. */
26typedef pthread_key_t __libc_key_t;
27
28/* If we check for a weakly referenced symbol and then perform a
29 normal jump to it te code generated for some platforms in case of
30 PIC is unnecessarily slow. What would happen is that the function
31 is first referenced as data and then it is called indirectly
32 through the PLT. We can make this a direct jump. */
33#ifdef __PIC__
34# define __libc_maybe_call(FUNC, ARGS, ELSE) \
35 (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
36 _fn != NULL ? (*_fn) ARGS : ELSE; }))
37#else
38# define __libc_maybe_call(FUNC, ARGS, ELSE) \
39 (FUNC != NULL ? FUNC ARGS : ELSE)
40#endif
41
42/* Call thread functions through the function pointer table. */
43#if defined SHARED && IS_IN (libc)
44# define PTFAVAIL(NAME) __libc_pthread_functions_init
45# define __libc_ptf_call(FUNC, ARGS, ELSE) \
46 (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE)
47# define __libc_ptf_call_always(FUNC, ARGS) \
48 PTHFCT_CALL (ptr_##FUNC, ARGS)
49#elif IS_IN (libpthread)
50# define PTFAVAIL(NAME) 1
51# define __libc_ptf_call(FUNC, ARGS, ELSE) \
52 FUNC ARGS
53# define __libc_ptf_call_always(FUNC, ARGS) \
54 FUNC ARGS
55#else
56# define PTFAVAIL(NAME) (NAME != NULL)
57# define __libc_ptf_call(FUNC, ARGS, ELSE) \
58 __libc_maybe_call (FUNC, ARGS, ELSE)
59# define __libc_ptf_call_always(FUNC, ARGS) \
60 FUNC ARGS
61#endif
62
63/* Create thread-specific key. */
64#define __libc_key_create(KEY, DESTRUCTOR) \
65 __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)
66
67/* Get thread-specific data. */
68#define __libc_getspecific(KEY) \
69 __libc_ptf_call (__pthread_getspecific, (KEY), NULL)
70
71/* Set thread-specific data. */
72#define __libc_setspecific(KEY, VALUE) \
73 __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
74
75
76/* Functions that are used by this file and are internal to the GNU C
77 library. */
78
79extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
80 const pthread_mutexattr_t *__mutex_attr);
81
82extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
83
84extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
85
86extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
87
88extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
89
90extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
91
92extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
93
94extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
95 int __kind);
96
97extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
98 const pthread_rwlockattr_t *__attr);
99
100extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
101
102extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
103
104extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
105
106extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
107
108extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
109
110extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
111
112extern int __pthread_key_create (pthread_key_t *__key,
113 void (*__destr_function) (void *));
114
115extern int __pthread_setspecific (pthread_key_t __key,
116 const void *__pointer);
117
118extern void *__pthread_getspecific (pthread_key_t __key);
119
120extern int __pthread_once (pthread_once_t *__once_control,
121 void (*__init_routine) (void));
122
123extern int __pthread_atfork (void (*__prepare) (void),
124 void (*__parent) (void),
125 void (*__child) (void));
126
127
128
129/* Make the pthread functions weak so that we can elide them from
130 single-threaded processes. */
131#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread)
132# ifdef weak_extern
133weak_extern (__pthread_mutex_init)
134weak_extern (__pthread_mutex_destroy)
135weak_extern (__pthread_mutex_lock)
136weak_extern (__pthread_mutex_trylock)
137weak_extern (__pthread_mutex_unlock)
138weak_extern (__pthread_mutexattr_init)
139weak_extern (__pthread_mutexattr_destroy)
140weak_extern (__pthread_mutexattr_settype)
141weak_extern (__pthread_rwlock_init)
142weak_extern (__pthread_rwlock_destroy)
143weak_extern (__pthread_rwlock_rdlock)
144weak_extern (__pthread_rwlock_tryrdlock)
145weak_extern (__pthread_rwlock_wrlock)
146weak_extern (__pthread_rwlock_trywrlock)
147weak_extern (__pthread_rwlock_unlock)
148weak_extern (__pthread_key_create)
149weak_extern (__pthread_setspecific)
150weak_extern (__pthread_getspecific)
151weak_extern (__pthread_once)
152weak_extern (__pthread_initialize)
153weak_extern (__pthread_atfork)
154weak_extern (__pthread_setcancelstate)
155# else
156# pragma weak __pthread_mutex_init
157# pragma weak __pthread_mutex_destroy
158# pragma weak __pthread_mutex_lock
159# pragma weak __pthread_mutex_trylock
160# pragma weak __pthread_mutex_unlock
161# pragma weak __pthread_mutexattr_init
162# pragma weak __pthread_mutexattr_destroy
163# pragma weak __pthread_mutexattr_settype
164# pragma weak __pthread_rwlock_destroy
165# pragma weak __pthread_rwlock_rdlock
166# pragma weak __pthread_rwlock_tryrdlock
167# pragma weak __pthread_rwlock_wrlock
168# pragma weak __pthread_rwlock_trywrlock
169# pragma weak __pthread_rwlock_unlock
170# pragma weak __pthread_key_create
171# pragma weak __pthread_setspecific
172# pragma weak __pthread_getspecific
173# pragma weak __pthread_once
174# pragma weak __pthread_initialize
175# pragma weak __pthread_atfork
176# pragma weak __pthread_setcancelstate
177# endif
178#endif
179
180#endif /* bits/libc-lockP.h */
libc/glibc/sysdeps/htl/pthread.h created+883
...@@ -0,0 +1,883 @@
1/* Posix threads. Hurd version.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * POSIX Threads Extension: ??? <pthread.h>
21 */
22
23#ifndef _PTHREAD_H
24#define _PTHREAD_H 1
25
26#include <features.h>
27
28#include <sys/cdefs.h>
29#ifndef __extern_inline
30/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
31 inline semantics, unless -fgnu89-inline is used. */
32# if !defined __cplusplus || __GNUC_PREREQ (4,3)
33# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
34# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
35# if __GNUC_PREREQ (4,3)
36# define __extern_always_inline \
37 extern __always_inline __attribute__ ((__gnu_inline__, __artificial__))
38# else
39# define __extern_always_inline \
40 extern __always_inline __attribute__ ((__gnu_inline__))
41# endif
42# else
43# define __extern_inline extern __inline
44# define __extern_always_inline extern __always_inline
45# endif
46# endif
47#endif
48
49#include <sched.h>
50#include <time.h>
51
52__BEGIN_DECLS
53
54#include <bits/pthreadtypes.h>
55
56#include <bits/pthread.h>
57
58/* Possible values for the process shared attribute. */
59#define PTHREAD_PROCESS_PRIVATE __PTHREAD_PROCESS_PRIVATE
60#define PTHREAD_PROCESS_SHARED __PTHREAD_PROCESS_SHARED
61
62
63/* Thread attributes. */
64
65/* Possible values for the inheritsched attribute. */
66#define PTHREAD_EXPLICIT_SCHED __PTHREAD_EXPLICIT_SCHED
67#define PTHREAD_INHERIT_SCHED __PTHREAD_INHERIT_SCHED
68
69/* Possible values for the `contentionscope' attribute. */
70#define PTHREAD_SCOPE_SYSTEM __PTHREAD_SCOPE_SYSTEM
71#define PTHREAD_SCOPE_PROCESS __PTHREAD_SCOPE_PROCESS
72
73/* Possible values for the `detachstate' attribute. */
74#define PTHREAD_CREATE_JOINABLE __PTHREAD_CREATE_JOINABLE
75#define PTHREAD_CREATE_DETACHED __PTHREAD_CREATE_DETACHED
76
77#include <bits/types/struct___pthread_attr.h>
78
79/* Initialize the thread attribute object in *ATTR to the default
80 values. */
81extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
82
83/* Destroy the thread attribute object in *ATTR. */
84extern int pthread_attr_destroy (pthread_attr_t *__attr)
85 __THROW __nonnull ((1));
86
87
88/* Return the value of the inheritsched attribute in *ATTR in
89 *INHERITSCHED. */
90extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict __attr,
91 int *__restrict __inheritsched)
92 __THROW __nonnull ((1, 2));
93
94/* Set the value of the inheritsched attribute in *ATTR to
95 INHERITSCHED. */
96extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
97 int __inheritsched)
98 __THROW __nonnull ((1));
99
100
101/* Return the value of the schedparam attribute in *ATTR in *PARAM. */
102extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
103 struct sched_param *__restrict __param)
104 __THROW __nonnull ((1, 2));
105
106/* Set the value of the schedparam attribute in *ATTR to PARAM. */
107extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
108 const struct sched_param *__restrict
109 __param) __THROW __nonnull ((1, 2));
110
111
112/* Return the value of the schedpolicy attribute in *ATTR to *POLICY. */
113extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict __attr,
114 int *__restrict __policy)
115 __THROW __nonnull ((1, 2));
116
117/* Set the value of the schedpolicy attribute in *ATTR to POLICY. */
118extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr,
119 int __policy)
120 __THROW __nonnull ((1));
121
122
123/* Return the value of the contentionscope attribute in *ATTR in
124 *CONTENTIONSCOPE. */
125extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
126 int *__restrict __contentionscope)
127 __THROW __nonnull ((1, 2));
128
129/* Set the value of the contentionscope attribute in *ATTR to
130 CONTENTIONSCOPE. */
131extern int pthread_attr_setscope (pthread_attr_t *__attr,
132 int __contentionscope)
133 __THROW __nonnull ((1));
134
135
136/* Return the value of the stackaddr attribute in *ATTR in
137 *STACKADDR. */
138extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict __attr,
139 void **__restrict __stackaddr)
140 __THROW __nonnull ((1, 2));
141
142/* Set the value of the stackaddr attribute in *ATTR to STACKADDR. */
143extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
144 void *__stackaddr)
145 __THROW __nonnull ((1));
146
147
148#ifdef __USE_XOPEN2K
149/* Return the value of the stackaddr and stacksize attributes in *ATTR
150 in *STACKADDR and *STACKSIZE respectively. */
151extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
152 void **__restrict __stackaddr,
153 size_t *__restrict __stacksize)
154 __THROW __nonnull ((1, 2, 3));
155
156/* Set the value of the stackaddr and stacksize attributes in *ATTR to
157 STACKADDR and STACKSIZE respectively. */
158extern int pthread_attr_setstack (pthread_attr_t *__attr,
159 void *__stackaddr,
160 size_t __stacksize)
161 __THROW __nonnull ((1));
162#endif
163
164
165/* Return the value of the detachstate attribute in *ATTR in
166 *DETACHSTATE. */
167extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
168 int *__detachstate)
169 __THROW __nonnull ((1, 2));
170
171/* Set the value of the detachstate attribute in *ATTR to
172 DETACHSTATE. */
173extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
174 int __detachstate)
175 __THROW __nonnull ((1));
176
177
178/* Return the value of the guardsize attribute in *ATTR in
179 *GUARDSIZE. */
180extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict __attr,
181 size_t *__restrict __guardsize)
182 __THROW __nonnull ((1, 2));
183
184/* Set the value of the guardsize attribute in *ATTR to GUARDSIZE. */
185extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
186 size_t __guardsize)
187 __THROW __nonnull ((1));
188
189
190/* Return the value of the stacksize attribute in *ATTR in
191 *STACKSIZE. */
192extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict __attr,
193 size_t *__restrict __stacksize)
194 __THROW __nonnull ((1, 2));
195
196/* Set the value of the stacksize attribute in *ATTR to STACKSIZE. */
197extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
198 size_t __stacksize)
199 __THROW __nonnull ((1));
200
201#ifdef __USE_GNU
202/* Initialize thread attribute *ATTR with attributes corresponding to the
203 already running thread THREAD. It shall be called on an uninitialized ATTR
204 and destroyed with pthread_attr_destroy when no longer needed. */
205extern int pthread_getattr_np (pthread_t __thr, pthread_attr_t *__attr)
206 __THROW __nonnull ((2));
207#endif
208
209
210/* Create a thread with attributes given by ATTR, executing
211 START_ROUTINE with argument ARG. */
212extern int pthread_create (pthread_t *__restrict __threadp,
213 __const pthread_attr_t *__restrict __attr,
214 void *(*__start_routine)(void *),
215 void *__restrict __arg) __THROWNL __nonnull ((1, 3));
216
217/* Terminate the current thread and make STATUS available to any
218 thread that might join us. */
219extern void pthread_exit (void *__status) __attribute__ ((__noreturn__));
220
221/* Make calling thread wait for termination of thread THREAD. Return
222 the exit status of the thread in *STATUS. */
223extern int pthread_join (pthread_t __threadp, void **__status);
224
225/* Indicate that the storage for THREAD can be reclaimed when it
226 terminates. */
227extern int pthread_detach (pthread_t __threadp);
228
229/* Compare thread IDs T1 and T2. Return nonzero if they are equal, 0
230 if they are not. */
231extern int pthread_equal (pthread_t __t1, pthread_t __t2);
232
233#ifdef __USE_EXTERN_INLINES
234
235__extern_inline int
236pthread_equal (pthread_t __t1, pthread_t __t2)
237{
238 return __pthread_equal (__t1, __t2);
239}
240
241#endif /* Use extern inlines. */
242
243
244/* Return the thread ID of the calling thread. */
245extern pthread_t pthread_self (void) __THROW;
246
247
248/* Mutex attributes. */
249
250#define PTHREAD_PRIO_NONE_NP __PTHREAD_PRIO_NONE
251#define PTHREAD_PRIO_INHERIT_NP __PTHREAD_PRIO_INHERIT
252#define PTHREAD_PRIO_PROTECT_NP __PTHREAD_PRIO_PROTECT
253#ifdef __USE_UNIX98
254# define PTHREAD_PRIO_NONE PTHREAD_PRIO_NONE_NP
255# define PTHREAD_PRIO_INHERIT PTHREAD_PRIO_INHERIT_NP
256# define PTHREAD_PRIO_PROTECT PTHREAD_PRIO_PROTECT_NP
257#endif
258
259#define PTHREAD_MUTEX_TIMED_NP __PTHREAD_MUTEX_TIMED
260#define PTHREAD_MUTEX_ERRORCHECK_NP __PTHREAD_MUTEX_ERRORCHECK
261#define PTHREAD_MUTEX_RECURSIVE_NP __PTHREAD_MUTEX_RECURSIVE
262#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
263# define PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_TIMED_NP
264# define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK_NP
265# define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
266# define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
267#endif
268#ifdef __USE_GNU
269/* For compatibility. */
270# define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_TIMED_NP
271#endif
272
273#ifdef __USE_XOPEN2K
274# define PTHREAD_MUTEX_STALLED __PTHREAD_MUTEX_STALLED
275# define PTHREAD_MUTEX_ROBUST __PTHREAD_MUTEX_ROBUST
276#endif
277
278#include <bits/types/struct___pthread_mutexattr.h>
279
280/* Initialize the mutex attribute object in *ATTR to the default
281 values. */
282extern int pthread_mutexattr_init(pthread_mutexattr_t *__attr)
283 __THROW __nonnull ((1));
284
285/* Destroy the mutex attribute structure in *ATTR. */
286extern int pthread_mutexattr_destroy(pthread_mutexattr_t *__attr)
287 __THROW __nonnull ((1));
288
289
290#ifdef __USE_UNIX98
291/* Return the value of the prioceiling attribute in *ATTR in
292 *PRIOCEILING. */
293extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict __attr,
294 int *__restrict __prioceiling)
295 __THROW __nonnull ((1, 2));
296
297/* Set the value of the prioceiling attribute in *ATTR to
298 PRIOCEILING. */
299extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *__attr,
300 int __prioceiling)
301 __THROW __nonnull ((1));
302
303
304/* Return the value of the protocol attribute in *ATTR in
305 *PROTOCOL. */
306extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict __attr,
307 int *__restrict __protocol)
308 __THROW __nonnull ((1, 2));
309
310/* Set the value of the protocol attribute in *ATTR to PROTOCOL. */
311extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *__attr,
312 int __protocol)
313 __THROW __nonnull ((1));
314#endif
315
316#ifdef __USE_XOPEN2K
317/* Get the robustness flag of the mutex attribute ATTR. */
318extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
319 int *__robustness)
320 __THROW __nonnull ((1, 2));
321# ifdef __USE_GNU
322extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
323 int *__robustness)
324 __THROW __nonnull ((1, 2));
325# endif
326
327/* Set the robustness flag of the mutex attribute ATTR. */
328extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
329 int __robustness)
330 __THROW __nonnull ((1));
331# ifdef __USE_GNU
332extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
333 int __robustness)
334 __THROW __nonnull ((1));
335# endif
336#endif
337
338
339/* Return the value of the process shared attribute in *ATTR in
340 *PSHARED. */
341extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict __attr,
342 int *__restrict __pshared)
343 __THROW __nonnull ((1, 2));
344
345/* Set the value of the process shared attribute in *ATTR to
346 PSHARED. */
347extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *__attr,
348 int __pshared)
349 __THROW __nonnull ((1));
350
351
352#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
353/* Return the value of the type attribute in *ATTR in *TYPE. */
354extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict __attr,
355 int *__restrict __type)
356 __THROW __nonnull ((1, 2));
357
358/* Set the value of the type attribute in *ATTR to TYPE. */
359extern int pthread_mutexattr_settype(pthread_mutexattr_t *__attr,
360 int __type)
361 __THROW __nonnull ((1));
362#endif
363
364
365/* Mutexes. */
366
367#include <bits/types/struct___pthread_mutex.h>
368
369#define PTHREAD_MUTEX_INITIALIZER __PTHREAD_MUTEX_INITIALIZER
370/* Static initializer for recursive mutexes. */
371
372#ifdef __USE_GNU
373# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
374 __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
375# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
376 __PTHREAD_RECURSIVE_MUTEX_INITIALIZER
377#endif
378
379/* Create a mutex with attributes given by ATTR and store it in
380 *__MUTEX. */
381extern int pthread_mutex_init (struct __pthread_mutex *__restrict __mutex,
382 const pthread_mutexattr_t *__restrict __attr)
383 __THROW __nonnull ((1));
384
385/* Destroy the mutex __MUTEX. */
386extern int pthread_mutex_destroy (struct __pthread_mutex *__mutex)
387 __THROW __nonnull ((1));
388
389/* Wait until lock for MUTEX becomes available and lock it. */
390extern int pthread_mutex_lock (pthread_mutex_t *__mutex);
391
392/* Try to lock MUTEX. */
393extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
394 __THROWNL __nonnull ((1));
395
396#ifdef __USE_XOPEN2K
397/* Try to lock MUTEX, block until *ABSTIME if it is already held. */
398extern int pthread_mutex_timedlock (struct __pthread_mutex *__restrict __mutex,
399 const struct timespec *__restrict __abstime)
400 __THROWNL __nonnull ((1, 2));
401#endif
402
403/* Unlock MUTEX. */
404extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
405 __THROWNL __nonnull ((1));
406
407/* Transfer ownership of the mutex MUTEX to the thread TID. The
408 caller must own the lock. */
409extern int __pthread_mutex_transfer_np (struct __pthread_mutex *__mutex,
410 pthread_t __tid)
411 __THROWNL __nonnull ((1));
412
413
414#ifdef __USE_UNIX98
415/* Return the priority ceiling of mutex *MUTEX in *PRIOCEILING. */
416extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict __mutex,
417 int *__restrict __prioceiling)
418 __THROW __nonnull ((1, 2));
419
420/* After acquiring the mutex *MUTEX, set its priority ceiling to PRIO
421 and return the old priority ceiling in *OLDPRIO. Before returning,
422 release the mutex. */
423extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
424 int __prio, int *__restrict __oldprio)
425 __THROW __nonnull ((1, 3));
426#endif
427
428#ifdef __USE_XOPEN2K8
429
430/* Declare the state protected by robust mutex MTXP as consistent. */
431extern int pthread_mutex_consistent (pthread_mutex_t *__mtxp)
432 __THROW __nonnull ((1));
433
434# ifdef __USE_GNU
435extern int pthread_mutex_consistent_np (pthread_mutex_t *__mtxp)
436 __THROW __nonnull ((1));
437# endif
438#endif
439
440
441
442/* Condition attributes. */
443
444#include <bits/types/struct___pthread_condattr.h>
445
446/* Initialize the condition attribute in *ATTR to the default
447 values. */
448extern int pthread_condattr_init (pthread_condattr_t *__attr)
449 __THROW __nonnull ((1));
450
451/* Destroy the condition attribute structure in *ATTR. */
452extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
453 __THROW __nonnull ((1));
454
455
456#ifdef __USE_XOPEN2K
457/* Return the value of the clock attribute in *ATTR in *CLOCK_ID. */
458extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict __attr,
459 __clockid_t *__restrict __clock_id)
460 __THROW __nonnull ((1, 2));
461
462/* Set the value of the clock attribute in *ATTR to CLOCK_ID. */
463extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
464 __clockid_t __clock_id)
465 __THROW __nonnull ((1));
466#endif
467
468
469/* Return the value of the process shared attribute in *ATTR in
470 *PSHARED. */
471extern int pthread_condattr_getpshared (const pthread_condattr_t *__restrict __attr,
472 int *__restrict __pshared)
473 __THROW __nonnull ((1, 2));
474
475/* Set the value of the process shared attribute in *ATTR to
476 PSHARED. */
477extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
478 int __pshared)
479 __THROW __nonnull ((1));
480
481
482/* Condition variables. */
483
484#include <bits/types/struct___pthread_cond.h>
485
486#define PTHREAD_COND_INITIALIZER __PTHREAD_COND_INITIALIZER
487
488extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
489 const pthread_condattr_t *__restrict __attr)
490 __THROW __nonnull ((1));
491
492extern int pthread_cond_destroy (pthread_cond_t *__cond)
493 __THROW __nonnull ((1));
494
495/* Unblock at least one of the threads that are blocked on condition
496 variable COND. */
497extern int pthread_cond_signal (pthread_cond_t *__cond)
498 __THROWNL __nonnull ((1));
499
500/* Unblock all threads that are blocked on condition variable COND. */
501extern int pthread_cond_broadcast (pthread_cond_t *__cond)
502 __THROWNL __nonnull ((1));
503
504/* Block on condition variable COND. MUTEX should be held by the
505 calling thread. On success, MUTEX will be held by the calling
506 thread. */
507extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
508 pthread_mutex_t *__restrict __mutex)
509 __nonnull ((1, 2));
510
511/* Block on condition variable COND. MUTEX should be held by the
512 calling thread. On success, MUTEX will be held by the calling
513 thread. If the time specified by ABSTIME passes, ETIMEDOUT is
514 returned, and MUTEX will nevertheless be held. */
515extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
516 pthread_mutex_t *__restrict __mutex,
517 __const struct timespec *__restrict __abstime)
518 __nonnull ((1, 2, 3));
519
520
521/* Spin locks. */
522
523#ifdef __USE_XOPEN2K
524
525# include <bits/types/__pthread_spinlock_t.h>
526
527# define PTHREAD_SPINLOCK_INITIALIZER __PTHREAD_SPIN_LOCK_INITIALIZER
528
529/* Destroy the spin lock object LOCK. */
530extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
531 __nonnull ((1));
532
533/* Initialize the spin lock object LOCK. PSHARED determines whether
534 the spin lock can be operated upon by multiple processes. */
535extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
536 __nonnull ((1));
537
538/* Lock the spin lock object LOCK. If the lock is held by another
539 thread spin until it becomes available. */
540extern int pthread_spin_lock (pthread_spinlock_t *__lock)
541 __nonnull ((1));
542
543/* Lock the spin lock object LOCK. Fail if the lock is held by
544 another thread. */
545extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
546 __nonnull ((1));
547
548/* Unlock the spin lock object LOCK. */
549extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
550 __nonnull ((1));
551
552# if defined __USE_EXTERN_INLINES && defined _LIBC
553
554# include <bits/spin-lock-inline.h>
555
556__extern_inline int
557pthread_spin_destroy (pthread_spinlock_t *__lock)
558{
559 return __pthread_spin_destroy (__lock);
560}
561
562__extern_inline int
563pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
564{
565 return __pthread_spin_init (__lock, __pshared);
566}
567
568__extern_inline int
569pthread_spin_lock (pthread_spinlock_t *__lock)
570{
571 return __pthread_spin_lock (__lock);
572}
573
574__extern_inline int
575pthread_spin_trylock (pthread_spinlock_t *__lock)
576{
577 return __pthread_spin_trylock (__lock);
578}
579
580__extern_inline int
581pthread_spin_unlock (pthread_spinlock_t *__lock)
582{
583 return __pthread_spin_unlock (__lock);
584}
585
586# endif /* Use extern inlines. */
587
588#endif /* XPG6. */
589
590
591/* rwlock attributes. */
592
593#if defined __USE_UNIX98 || defined __USE_XOPEN2K
594
595# include <bits/types/struct___pthread_rwlockattr.h>
596
597/* Initialize rwlock attribute object in *ATTR to the default
598 values. */
599extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
600 __THROW __nonnull ((1));
601
602/* Destroy the rwlock attribute object in *ATTR. */
603extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
604 __THROW __nonnull ((1));
605
606
607/* Return the value of the process shared attribute in *ATTR in
608 *PSHARED. */
609extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *__restrict __attr,
610 int *__restrict __pshared)
611 __THROW __nonnull ((1, 2));
612
613/* Set the value of the process shared atrribute in *ATTR to
614 PSHARED. */
615extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
616 int __pshared)
617 __THROW __nonnull ((1));
618
619/* Return current setting of reader/writer preference. */
620extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
621 __restrict __attr,
622 int *__restrict __pref)
623 __THROW __nonnull ((1, 2));
624
625/* Set reader/write preference. */
626extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
627 int __pref) __THROW __nonnull ((1));
628
629
630/* rwlocks. */
631
632# include <bits/types/struct___pthread_rwlock.h>
633
634# define PTHREAD_RWLOCK_INITIALIZER __PTHREAD_RWLOCK_INITIALIZER
635/* Create a rwlock object with attributes given by ATTR and strore the
636 result in *RWLOCK. */
637extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
638 const pthread_rwlockattr_t *__restrict __attr)
639 __THROW __nonnull ((1));
640
641/* Destroy the rwlock *RWLOCK. */
642extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
643 __THROW __nonnull ((1));
644
645/* Acquire the rwlock *RWLOCK for reading. */
646extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
647 __THROWNL __nonnull ((1));
648
649/* Acquire the rwlock *RWLOCK for reading. */
650extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
651 __THROWNL __nonnull ((1));
652
653# ifdef __USE_XOPEN2K
654/* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if
655 it is already held. */
656extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *__restrict __rwlock,
657 const struct timespec *__restrict __abstime)
658 __THROWNL __nonnull ((1, 2));
659# endif
660
661/* Acquire the rwlock *RWLOCK for writing. */
662extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
663 __THROWNL __nonnull ((1));
664
665/* Try to acquire the rwlock *RWLOCK for writing. */
666extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
667 __THROWNL __nonnull ((1));
668
669# ifdef __USE_XOPEN2K
670/* Acquire the rwlock *RWLOCK for writing blocking until *ABSTIME if
671 it is already held. */
672extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *__restrict __rwlock,
673 const struct timespec *__restrict __abstime)
674 __THROWNL __nonnull ((1, 2));
675# endif
676
677/* Release the lock held by the current thread on *RWLOCK. */
678extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
679 __THROWNL __nonnull ((1));
680
681#endif /* __USE_UNIX98 || __USE_XOPEN2K */
682
683
684
685/* Cancelation. */
686
687/* Register a cleanup handler. */
688extern void pthread_cleanup_push (void (*__routine) (void *), void *__arg);
689
690/* Unregister a cleanup handler. */
691extern void pthread_cleanup_pop (int __execute);
692
693#include <bits/cancelation.h>
694
695#define pthread_cleanup_push(rt, rtarg) __pthread_cleanup_push(rt, rtarg)
696#define pthread_cleanup_pop(execute) __pthread_cleanup_pop(execute)
697
698#define PTHREAD_CANCEL_DISABLE 0
699#define PTHREAD_CANCEL_ENABLE 1
700
701/* Return the calling thread's cancelation state in *OLDSTATE and set
702 its state to STATE. */
703extern int pthread_setcancelstate (int __state, int *__oldstate);
704
705#define PTHREAD_CANCEL_DEFERRED 0
706#define PTHREAD_CANCEL_ASYNCHRONOUS 1
707
708/* Return the calling thread's cancelation type in *OLDTYPE and set
709 its type to TYPE. */
710extern int pthread_setcanceltype (int __type, int *__oldtype);
711
712/* Value returned by pthread_join if the target thread was
713 canceled. */
714#define PTHREAD_CANCELED ((void *) -1)
715
716/* Cancel THEAD. */
717extern int pthread_cancel (pthread_t __thr);
718
719/* Add an explicit cancelation point. */
720extern void pthread_testcancel (void);
721
722
723/* Barriers attributes. */
724
725#ifdef __USE_XOPEN2K
726
727# include <bits/types/struct___pthread_barrierattr.h>
728
729/* Initialize barrier attribute object in *ATTR to the default
730 values. */
731extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
732 __THROW __nonnull ((1));
733
734/* Destroy the barrier attribute object in *ATTR. */
735extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
736 __THROW __nonnull ((1));
737
738
739/* Return the value of the process shared attribute in *ATTR in
740 *PSHARED. */
741extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *__restrict __attr,
742 int *__restrict __pshared)
743 __THROW __nonnull ((1, 2));
744
745/* Set the value of the process shared atrribute in *ATTR to
746 PSHARED. */
747extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
748 int __pshared)
749 __THROW __nonnull ((1));
750
751
752/* Barriers. */
753
754# include <bits/types/struct___pthread_barrier.h>
755
756/* Returned by pthread_barrier_wait to exactly one thread each time a
757 barrier is passed. */
758# define PTHREAD_BARRIER_SERIAL_THREAD -1
759
760/* Initialize barrier BARRIER. */
761extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
762 const pthread_barrierattr_t *__restrict __attr,
763 unsigned __count)
764 __THROW __nonnull ((1));
765
766/* Destroy barrier BARRIER. */
767extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
768 __THROW __nonnull ((1));
769
770/* Wait on barrier BARRIER. */
771extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
772 __THROWNL __nonnull ((1));
773
774#endif /* __USE_XOPEN2K */
775
776
777
778/* Thread specific data. */
779
780#include <bits/types/__pthread_key.h>
781
782/* Create a thread specific data key in KEY visible to all threads.
783 On thread destruction, DESTRUCTOR shall be called with the thread
784 specific data associate with KEY if it is not NULL. */
785extern int pthread_key_create (pthread_key_t *__key,
786 void (*__destructor) (void *))
787 __THROW __nonnull ((1));
788
789/* Delete the thread specific data key KEY. The associated destructor
790 function is not called. */
791extern int pthread_key_delete (pthread_key_t __key) __THROW;
792
793/* Return the caller thread's thread specific value of KEY. */
794extern void *pthread_getspecific (pthread_key_t __key) __THROW;
795
796/* Set the caller thread's thread specific value of KEY to VALUE. */
797extern int pthread_setspecific (pthread_key_t __key, const void *__value)
798 __THROW;
799
800
801/* Dynamic package initialization. */
802
803#include <bits/types/struct___pthread_once.h>
804
805#define PTHREAD_ONCE_INIT __PTHREAD_ONCE_INIT
806
807/* Call INIT_ROUTINE if this function has never been called with
808 *ONCE_CONTROL, otherwise do nothing. */
809extern int pthread_once (pthread_once_t *__once_control,
810 void (*__init_routine) (void)) __nonnull ((1, 2));
811
812
813/* Concurrency. */
814
815#ifdef __USE_UNIX98
816/* Set the desired concurrency level to NEW_LEVEL. */
817extern int pthread_setconcurrency (int __new_level) __THROW;
818
819/* Get the current concurrency level. */
820extern int pthread_getconcurrency (void) __THROW;
821#endif
822
823
824/* Forking. */
825
826/* Register the function PREPARE to be run before the process forks,
827 the function PARENT to be run after a fork in the parent and the
828 function CHILD to be run in the child after the fork. If no
829 handling is desired then any of PREPARE, PARENT and CHILD may be
830 NULL. The prepare handles will be called in the reverse order
831 which they were registered and the parent and child handlers in the
832 order in which they were registered. */
833extern int pthread_atfork (void (*__prepare) (void), void (*__parent) (void),
834 void (*__child) (void)) __THROW;
835
836
837/* Signals (should be in <signal.h>). */
838
839/* Send signal SIGNO to thread THREAD. */
840extern int pthread_kill (pthread_t __thr, int __signo) __THROW;
841
842
843/* Time. */
844
845#ifdef __USE_XOPEN2K
846/* Return the thread cpu clock. */
847extern int pthread_getcpuclockid (pthread_t __thr, __clockid_t *__clock)
848 __THROW __nonnull ((2));
849#endif
850
851
852/* Scheduling. */
853
854/* Return thread THREAD's scheduling paramters. */
855extern int pthread_getschedparam (pthread_t __thr, int *__restrict __policy,
856 struct sched_param *__restrict __param)
857 __THROW __nonnull ((2, 3));
858
859/* Set thread THREAD's scheduling paramters. */
860extern int pthread_setschedparam (pthread_t __thr, int __policy,
861 const struct sched_param *__param)
862 __THROW __nonnull ((3));
863
864/* Set thread THREAD's scheduling priority. */
865extern int pthread_setschedprio (pthread_t __thr, int __prio) __THROW;
866
867#ifdef __USE_GNU
868/* Yield the processor to another thread or process.
869 This function is similar to the POSIX `sched_yield' function but
870 might be differently implemented in the case of a m-on-n thread
871 implementation. */
872extern int pthread_yield (void) __THROW;
873#endif
874
875
876/* Kernel-specific interfaces. */
877
878#include <bits/pthread-np.h>
879
880
881__END_DECLS
882
883#endif /* pthread.h */
libc/glibc/sysdeps/i386/crti.S created+88
...@@ -0,0 +1,88 @@
1/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .p2align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 _CET_ENDBR
65 pushl %ebx
66 /* Maintain 16-byte stack alignment for called functions. */
67 subl $8, %esp
68 LOAD_PIC_REG (bx)
69#if PREINIT_FUNCTION_WEAK
70 movl PREINIT_FUNCTION@GOT(%ebx), %eax
71 testl %eax, %eax
72 je .Lno_weak_fn
73 call *%eax
74.Lno_weak_fn:
75#else
76 call PREINIT_FUNCTION
77#endif
78
79 .section .fini,"ax",@progbits
80 .p2align 2
81 .globl _fini
82 .hidden _fini
83 .type _fini, @function
84_fini:
85 _CET_ENDBR
86 pushl %ebx
87 subl $8, %esp
88 LOAD_PIC_REG (bx)
libc/glibc/sysdeps/i386/crtn.S created+47
...@@ -0,0 +1,47 @@
1/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 addl $8, %esp
41 popl %ebx
42 ret
43
44 .section .fini,"ax",@progbits
45 addl $8, %esp
46 popl %ebx
47 ret
libc/glibc/sysdeps/i386/htl/bits/pthreadtypes-arch.h created+22
...@@ -0,0 +1,22 @@
1/* Machine-specific pthread type layouts. Hurd i386 version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/i386/start.S created+151
...@@ -0,0 +1,151 @@
1/* Startup code compliant to the ELF i386 ABI.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* This is the canonical entry point, usually the first thing in the text
37 segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
38 point runs, most registers' values are unspecified, except for:
39
40 %edx Contains a function pointer to be registered with `atexit'.
41 This is how the dynamic linker arranges to have DT_FINI
42 functions called for shared libraries that have been loaded
43 before this code runs.
44
45 %esp The stack contains the arguments and environment:
46 0(%esp) argc
47 4(%esp) argv[0]
48 ...
49 (4*argc)(%esp) NULL
50 (4*(argc+1))(%esp) envp[0]
51 ...
52 NULL
53*/
54
55#include <sysdep.h>
56
57ENTRY (_start)
58 /* Clearing frame pointer is insufficient, use CFI. */
59 cfi_undefined (eip)
60 /* Clear the frame pointer. The ABI suggests this be done, to mark
61 the outermost frame obviously. */
62 xorl %ebp, %ebp
63
64 /* Extract the arguments as encoded on the stack and set up
65 the arguments for `main': argc, argv. envp will be determined
66 later in __libc_start_main. */
67 popl %esi /* Pop the argument count. */
68 movl %esp, %ecx /* argv starts just at the current stack top.*/
69
70 /* Before pushing the arguments align the stack to a 16-byte
71 (SSE needs 16-byte alignment) boundary to avoid penalties from
72 misaligned accesses. Thanks to Edward Seidl <seidl@janed.com>
73 for pointing this out. */
74 andl $0xfffffff0, %esp
75 pushl %eax /* Push garbage because we allocate
76 28 more bytes. */
77
78 /* Provide the highest stack address to the user code (for stacks
79 which grow downwards). */
80 pushl %esp
81
82 pushl %edx /* Push address of the shared library
83 termination function. */
84
85#ifdef PIC
86 /* Load PIC register. */
87 call 1f
88 addl $_GLOBAL_OFFSET_TABLE_, %ebx
89
90 /* Push address of our own entry points to .fini and .init. */
91 leal __libc_csu_fini@GOTOFF(%ebx), %eax
92 pushl %eax
93 leal __libc_csu_init@GOTOFF(%ebx), %eax
94 pushl %eax
95
96 pushl %ecx /* Push second argument: argv. */
97 pushl %esi /* Push first argument: argc. */
98
99# ifdef SHARED
100 pushl main@GOT(%ebx)
101# else
102 /* Avoid relocation in static PIE since _start is called before
103 it is relocated. Don't use "leal main@GOTOFF(%ebx), %eax"
104 since main may be in a shared object. Linker will convert
105 "movl main@GOT(%ebx), %eax" to "leal main@GOTOFF(%ebx), %eax"
106 if main is defined locally. */
107 movl main@GOT(%ebx), %eax
108 pushl %eax
109# endif
110
111 /* Call the user's main function, and exit with its value.
112 But let the libc call main. */
113 call __libc_start_main@PLT
114#else
115 /* Push address of our own entry points to .fini and .init. */
116 pushl $__libc_csu_fini
117 pushl $__libc_csu_init
118
119 pushl %ecx /* Push second argument: argv. */
120 pushl %esi /* Push first argument: argc. */
121
122 pushl $main
123
124 /* Call the user's main function, and exit with its value.
125 But let the libc call main. */
126 call __libc_start_main
127#endif
128
129 hlt /* Crash if somehow `exit' does return. */
130
131#ifdef PIC
1321: movl (%esp), %ebx
133 ret
134#endif
135END (_start)
136
137/* To fulfill the System V/i386 ABI we need this symbol. Yuck, it's so
138 meaningless since we don't support machines < 80386. */
139 .section .rodata
140 .globl _fp_hw
141_fp_hw: .long 3
142 .size _fp_hw, 4
143 .type _fp_hw,@object
144
145/* Define a symbol for the first piece of initialized data. */
146 .data
147 .globl __data_start
148__data_start:
149 .long 0
150 .weak data_start
151 data_start = __data_start
libc/glibc/sysdeps/i386/symbol-hacks.h created+21
...@@ -0,0 +1,21 @@
1/* Hacks needed for symbol manipulation. i386 version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
20
21#include_next "symbol-hacks.h"
libc/glibc/sysdeps/i386/sysdep.h created+116
...@@ -0,0 +1,116 @@
1/* Assembler macros for i386.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/x86/sysdep.h>
20
21#include <features.h> /* For __GNUC_PREREQ. */
22
23/* It is desirable that the names of PIC thunks match those used by
24 GCC so that multiple copies are eliminated by the linker. Because
25 GCC 4.6 and earlier use __i686 in the names, it is necessary to
26 override that predefined macro. */
27#if defined __i686 && defined __ASSEMBLER__
28#undef __i686
29#define __i686 __i686
30#endif
31
32#ifdef __ASSEMBLER__
33# define GET_PC_THUNK(reg) __x86.get_pc_thunk.reg
34#else
35# define GET_PC_THUNK_STR(reg) "__x86.get_pc_thunk." #reg
36#endif
37
38#ifdef __ASSEMBLER__
39
40/* Syntactic details of assembler. */
41
42/* If compiled for profiling, call `mcount' at the start of each function. */
43#ifdef PROF
44/* The mcount code relies on a normal frame pointer being on the stack
45 to locate our caller, so push one just for its benefit. */
46#define CALL_MCOUNT \
47 pushl %ebp; cfi_adjust_cfa_offset (4); movl %esp, %ebp; \
48 cfi_def_cfa_register (ebp); call JUMPTARGET(mcount); \
49 popl %ebp; cfi_def_cfa (esp, 4);
50#else
51#define CALL_MCOUNT /* Do nothing. */
52#endif
53
54#define PSEUDO(name, syscall_name, args) \
55 .globl syscall_error; \
56lose: SYSCALL_PIC_SETUP \
57 jmp JUMPTARGET(syscall_error); \
58 ENTRY (name) \
59 DO_CALL (syscall_name, args); \
60 jb lose
61
62# define SETUP_PIC_REG(reg) \
63 .ifndef GET_PC_THUNK(reg); \
64 .section .gnu.linkonce.t.GET_PC_THUNK(reg),"ax",@progbits; \
65 .globl GET_PC_THUNK(reg); \
66 .hidden GET_PC_THUNK(reg); \
67 .p2align 4; \
68 .type GET_PC_THUNK(reg),@function; \
69GET_PC_THUNK(reg): \
70 movl (%esp), %e##reg; \
71 ret; \
72 .size GET_PC_THUNK(reg), . - GET_PC_THUNK(reg); \
73 .previous; \
74 .endif; \
75 call GET_PC_THUNK(reg)
76
77# define LOAD_PIC_REG(reg) \
78 SETUP_PIC_REG(reg); addl $_GLOBAL_OFFSET_TABLE_, %e##reg
79
80#undef JUMPTARGET
81#ifdef PIC
82#define JUMPTARGET(name) name##@PLT
83#define SYSCALL_PIC_SETUP \
84 pushl %ebx; \
85 cfi_adjust_cfa_offset (4); \
86 call 0f; \
870: popl %ebx; \
88 cfi_adjust_cfa_offset (-4); \
89 addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx;
90
91#else
92#define JUMPTARGET(name) name
93#define SYSCALL_PIC_SETUP /* Nothing. */
94#endif
95
96#else /* __ASSEMBLER__ */
97
98# define SETUP_PIC_REG_STR(reg) \
99 ".ifndef " GET_PC_THUNK_STR (reg) "\n" \
100 ".section .gnu.linkonce.t." GET_PC_THUNK_STR (reg) ",\"ax\",@progbits\n" \
101 ".globl " GET_PC_THUNK_STR (reg) "\n" \
102 ".hidden " GET_PC_THUNK_STR (reg) "\n" \
103 ".p2align 4\n" \
104 ".type " GET_PC_THUNK_STR (reg) ",@function\n" \
105GET_PC_THUNK_STR (reg) ":" \
106 "movl (%%esp), %%e" #reg "\n" \
107 "ret\n" \
108 ".size " GET_PC_THUNK_STR (reg) ", . - " GET_PC_THUNK_STR (reg) "\n" \
109 ".previous\n" \
110 ".endif\n" \
111 "call " GET_PC_THUNK_STR (reg)
112
113# define LOAD_PIC_REG_STR(reg) \
114 SETUP_PIC_REG_STR (reg) "\naddl $_GLOBAL_OFFSET_TABLE_, %%e" #reg
115
116#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/ia64/crti.S created+162
...@@ -0,0 +1,162 @@
1/* Special .init and .fini section support for IA64.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43#undef ret
44
45#ifndef PREINIT_FUNCTION
46# define PREINIT_FUNCTION __gmon_start__
47#endif
48
49#ifndef PREINIT_FUNCTION_WEAK
50# define PREINIT_FUNCTION_WEAK 1
51#endif
52
53#if PREINIT_FUNCTION_WEAK
54 weak_extern (PREINIT_FUNCTION)
55#else
56 .hidden PREINIT_FUNCTION
57#endif
58
59/* If we have working .init_array support, we want to keep the .init
60 section empty (apart from the mandatory prologue/epilogue. This
61 ensures that the default unwind conventions (return-pointer in b0,
62 frame state in ar.pfs, etc.) will do the Right Thing. To ensure
63 an empty .init section, we register gmon_initializer() via the
64 .init_array.
65
66 --davidm 02/10/29 */
67
68#if PREINIT_FUNCTION_WEAK
69/* This blob of assembly code is one simple C function:
70
71static void
72__attribute__ ((used))
73gmon_initializer (void)
74{
75 extern void weak_function __gmon_start__ (void);
76
77 if (__gmon_start__)
78 (*__gmon_start__)();
79}
80 */
81 .text
82 .align 64
83 .proc gmon_initializer#
84gmon_initializer:
85 .prologue 12, 32
86 .mmi
87 .save ar.pfs, r33
88 alloc r33 = ar.pfs, 0, 3, 0, 0
89 addl r14 = @ltoff(@fptr(PREINIT_FUNCTION#)), gp
90 .save rp, r32
91 mov r32 = b0
92 .mmi
93 mov r34 = r1
94 .body
95 ;;
96 ld8 r14 = [r14]
97 nop 0
98 ;;
99 .mib
100 cmp.eq p6, p7 = 0, r14
101 nop 0
102 (p6) br.cond.spnt .L1
103 ;;
104 .mib
105 nop 0
106 nop 0
107 br.call.sptk.many b0 = PREINIT_FUNCTION#
108 ;;
109 .mmi
110 mov r1 = r34
111 nop 0
112 nop 0
113.L1:
114 .mii
115 nop 0
116 mov ar.pfs = r33
117 nop 0
118 ;;
119 .mib
120 nop 0
121 mov b0 = r32
122 br.ret.sptk.many b0
123 .endp gmon_initializer#
124# undef PREINIT_FUNCTION
125# define PREINIT_FUNCTION gmon_initializer
126#endif
127 .section .init_array, "aw"
128 data8 @fptr(PREINIT_FUNCTION)
129
130 .section .init,"ax",@progbits
131 .global _init#
132 .hidden _init#
133 .proc _init#
134_init:
135 .prologue
136 .save ar.pfs, r34
137 alloc r34 = ar.pfs, 0, 3, 0, 0
138 .vframe r32
139 mov r32 = r12
140 .save rp, r33
141 mov r33 = b0
142 .body
143 adds r12 = -16, r12
144 ;; /* see gmon_initializer() above */
145 .endp _init#
146
147 .section .fini,"ax",@progbits
148 .global _fini#
149 .hidden _fini#
150 .proc _fini#
151_fini:
152 .prologue
153 .save ar.pfs, r34
154 alloc r34 = ar.pfs, 0, 3, 0, 0
155 .vframe r32
156 mov r32 = r12
157 .save rp, r33
158 mov r33 = b0
159 .body
160 adds r12 = -16, r12
161 ;;
162 .endp _fini#
libc/glibc/sysdeps/ia64/crtn.S created+69
...@@ -0,0 +1,69 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37#undef ret
38
39/* crtn.S puts function epilogues in the .init and .fini sections
40 corresponding to the prologues in crti.S. */
41
42 .section .init,"ax",@progbits
43 .proc _init#
44_init:
45 .prologue
46 .save ar.pfs, r34
47 .vframe r32
48 .save rp, r33
49 .body
50 .regstk 0,2,0,0
51 mov r12 = r32
52 mov ar.pfs = r34
53 mov b0 = r33
54 br.ret.sptk.many b0
55 .endp _init#
56
57 .section .fini,"ax",@progbits
58 .proc _fini#
59_fini:
60 .prologue
61 .save ar.pfs, r34
62 .vframe r32
63 .save rp, r33
64 .body
65 mov r12 = r32
66 mov ar.pfs = r34
67 mov b0 = r33
68 br.ret.sptk.many b0
69 .endp _fini#
libc/glibc/sysdeps/ia64/dl-dtprocnum.h created+21
...@@ -0,0 +1,21 @@
1/* Configuration of lookup functions. IA-64 version.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Number of extra dynamic section entries for this architecture. By
20 default there are none. */
21#define DT_THISPROCNUM DT_IA_64_NUM
libc/glibc/sysdeps/ia64/dl-sysdep.h created+23
...@@ -0,0 +1,23 @@
1/* System-specific settings for dynamic linker code. IA-64 version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
libc/glibc/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#define __SIZEOF_PTHREAD_ATTR_T 56
23#define __SIZEOF_PTHREAD_MUTEX_T 40
24#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
25#define __SIZEOF_PTHREAD_COND_T 48
26#define __SIZEOF_PTHREAD_CONDATTR_T 4
27#define __SIZEOF_PTHREAD_RWLOCK_T 56
28#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
29#define __SIZEOF_PTHREAD_BARRIER_T 32
30#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
31
32/* Definitions for internal mutex struct. */
33#define __PTHREAD_COMPAT_PADDING_MID
34#define __PTHREAD_COMPAT_PADDING_END
35#define __PTHREAD_MUTEX_LOCK_ELISION 0
36#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
37#define __PTHREAD_MUTEX_USE_UNION 0
38
39#define __LOCK_ALIGNMENT
40#define __ONCE_ALIGNMENT
41
42/* Data structure for reader-write lock variable handling. The
43 structure of the attribute type is not exposed on purpose. */
44struct __pthread_rwlock_arch_t
45{
46 unsigned int __readers;
47 unsigned int __writers;
48 unsigned int __wrphase_futex;
49 unsigned int __writers_futex;
50 unsigned int __pad3;
51 unsigned int __pad4;
52 int __cur_writer;
53 int __shared;
54 unsigned long int __pad1;
55 unsigned long int __pad2;
56 /* FLAGS must stay at this position in the structure to maintain
57 binary compatibility. */
58 unsigned int __flags;
59};
60
61#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
62
63#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/ia64/start.S created+119
...@@ -0,0 +1,119 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38#include <asm/unistd.h>
39#include <asm/fpu.h>
40
41/*
42 * Arguments for __libc_start_main:
43 * out0: main
44 * out1: argc
45 * out2: argv
46 * out3: init
47 * out4: fini
48 * out5: rtld_fini
49 * out6: stack_end
50 */
51
52 .align 32
53 .global _start
54
55 .proc _start
56 .type _start,@function
57_start:
58 .prologue
59 .save rp, r0
60 .body
61 .prologue
62 { .mlx
63 alloc r2 = ar.pfs,0,0,7,0
64 movl r3 = FPSR_DEFAULT
65 }
66 { .mlx
67 adds out2 = 16, sp /* get address of argc value */
68 movl gp = @gprel(0f)
69 ;;
70 }
710: { .mmi
72 ld8 out1 = [out2], 8 /* load argc and move out2 to become argv */
73 mov.m r10 = ar.bsp /* fetch rbs base address */
74 mov r9 = ip
75 ;;
76 }
77 { .mii
78 mov ar.fpsr = r3
79 sub gp = r9, gp /* back-compute gp value */
80 adds out6 = 16, sp /* highest non-environment stack address */
81 ;;
82 }
83 {
84 addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
85 addl out0 = @ltoff(@fptr(main)), gp
86 addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
87 ;;
88 }
89 { .mmi
90 ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
91 ld8 out0 = [out0] /* pointer to `main' function descriptor */
92 addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
93 ;;
94 }
95 { .mmi
96 ld8 out3 = [out3] /* pointer to `init' function descriptor */
97 ld8 out4 = [out4] /* pointer to `fini' function descriptor */
98 nop 0
99 }
100 .body
101 { .mib
102 st8 [r3] = r10
103 mov out5 = ret0 /* dynamic linker destructor */
104 br.call.sptk.few rp = __libc_start_main
105 }
106 { .mib
107 break 0 /* break miserably if we ever return */
108 }
109 .endp _start
110
111/* Define a symbol for the first piece of initialized data. */
112 .data
113 .globl __data_start
114__data_start:
115 .long 0
116 .weak data_start
117 data_start = __data_start
118
119 .common __libc_ia64_register_backing_store_base, 8, 8
libc/glibc/sysdeps/ia64/sysdep.h created+62
...@@ -0,0 +1,62 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Macros to help writing .prologue directives in assembly code. */
24#define ASM_UNW_PRLG_RP 0x8
25#define ASM_UNW_PRLG_PFS 0x4
26#define ASM_UNW_PRLG_PSP 0x2
27#define ASM_UNW_PRLG_PR 0x1
28#define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs))
29
30#define ENTRY(name) \
31 .text; \
32 .align 32; \
33 .proc C_SYMBOL_NAME(name); \
34 .global C_SYMBOL_NAME(name); \
35 C_LABEL(name) \
36 CALL_MCOUNT
37
38#define LOCAL_ENTRY(name) \
39 .text; \
40 .align 32; \
41 .proc C_SYMBOL_NAME(name); \
42 C_LABEL(name) \
43 CALL_MCOUNT
44
45#define LEAF(name) \
46 .text; \
47 .align 32; \
48 .proc C_SYMBOL_NAME(name); \
49 .global name; \
50 C_LABEL(name)
51
52#define LOCAL_LEAF(name) \
53 .text; \
54 .align 32; \
55 .proc C_SYMBOL_NAME(name); \
56 C_LABEL(name)
57
58/* Mark the end of function SYM. */
59#undef END
60#define END(sym) .endp C_SYMBOL_NAME(sym)
61
62#endif /* ASSEMBLER */
libc/glibc/sysdeps/init_array/crti.S created+27
...@@ -0,0 +1,27 @@
1/* Dummy crti file.
2
3 In this configuration, crti.o and crtn.o are both empty because the
4 .init_array/.fini_array sections are used exclusively.
5
6 Older ports cannot use this because even if the linker used to
7 build libc itself has .init_array support, we don't want to produce
8 a crt[in].o that presume a linker that new will be used to link
9 other things later.
10
11 But new configurations without compatibility concerns for
12 toolchains without .init_array support can use this to avoid the
13 superfluous .init and .fini boilerplate code. */
14
15#ifdef PREINIT_FUNCTION
16
17#if PREINIT_FUNCTION_WEAK
18# error PREINIT_FUNCTION_WEAK is unsupported
19#endif
20
21/* This arranges for PREINIT_FUNCTION to be called upon loading a library that
22 contains crti.o. */
23
24 .section .init_array,"a",%init_array
25 .dc.a PREINIT_FUNCTION
26
27#endif
libc/glibc/sysdeps/init_array/crtn.S created+13
...@@ -0,0 +1,13 @@
1/* Dummy crtn file.
2
3 In this configuration, crti.o and crtn.o are both empty because the
4 .init_array/.fini_array sections are used exclusively.
5
6 Older ports cannot use this because even if the linker used to
7 build libc itself has .init_array support, we don't want to produce
8 a crt[in].o that presume a linker that new will be used to link
9 other things later.
10
11 But new configurations without compatibility concerns for
12 toolchains without .init_array support can use this to avoid the
13 superfluous .init and .fini boilerplate code. */
libc/glibc/sysdeps/m68k/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* m68k is big-endian. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __BIG_ENDIAN
libc/glibc/sysdeps/m68k/coldfire/sysdep.h created+40
...@@ -0,0 +1,40 @@
1/* Assembler macros for Coldfire.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/m68k/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Perform operation OP with PC-relative SRC as the first operand and
24 DST as the second. TMP is available as a temporary if needed. */
25# define PCREL_OP(OP, SRC, DST, TMP) \
26 move.l &SRC - ., TMP; OP (-8, %pc, TMP), DST
27
28/* Load the address of the GOT into register R. */
29# define LOAD_GOT(R) \
30 move.l &_GLOBAL_OFFSET_TABLE_@GOTPC, R; \
31 lea (-6, %pc, R), R
32
33#else
34
35/* As above, but PC is the spelling of the PC register. We need this
36 so that the macro can be used in both normal and extended asms. */
37# define PCREL_OP(OP, SRC, DST, TMP, PC) \
38 "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST
39
40#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/m68k/crti.S created+84
...@@ -0,0 +1,84 @@
1/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 link.w %fp, #0
65 move.l %a5, -(%sp)
66 LOAD_GOT (%a5)
67#if PREINIT_FUNCTION_WEAK
68 tst.l PREINIT_FUNCTION@GOT(%a5)
69 jeq 1f
70 jbsr PREINIT_FUNCTION@PLTPC
711:
72#else
73 jbsr PREINIT_FUNCTION
74#endif
75
76 .section .fini,"ax",@progbits
77 .align 2
78 .globl _fini
79 .hidden _fini
80 .type _fini, @function
81_fini:
82 link.w %fp, #0
83 move.l %a5, -(%sp)
84 LOAD_GOT (%a5)
libc/glibc/sysdeps/m68k/crtn.S created+47
...@@ -0,0 +1,47 @@
1/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 move.l -4(%fp), %a5
41 unlk %fp
42 rts
43
44 .section .fini,"ax",@progbits
45 move.l -4(%fp), %a5
46 unlk %fp
47 rts
libc/glibc/sysdeps/m68k/m680x0/sysdep.h created+39
...@@ -0,0 +1,39 @@
1/* Assembler macros for m680x0.
2 Copyright (C) 2010-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/m68k/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Perform operation OP with PC-relative SRC as the first operand and
24 DST as the second. TMP is available as a temporary if needed. */
25# define PCREL_OP(OP, SRC, DST, TMP) \
26 OP SRC(%pc), DST
27
28/* Load the address of the GOT into register R. */
29# define LOAD_GOT(R) \
30 lea _GLOBAL_OFFSET_TABLE_@GOTPC (%pc), R
31
32#else
33
34/* As above, but PC is the spelling of the PC register. We need this
35 so that the macro can be used in both normal and extended asms. */
36#define PCREL_OP(OP, SRC, DST, TMP, PC) \
37 OP " " SRC "(" PC "), " DST
38
39#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <endian.h>
23
24#define __SIZEOF_PTHREAD_ATTR_T 36
25#define __SIZEOF_PTHREAD_MUTEX_T 24
26#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
27#define __SIZEOF_PTHREAD_COND_T 48
28#define __SIZEOF_PTHREAD_CONDATTR_T 4
29#define __SIZEOF_PTHREAD_RWLOCK_T 32
30#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
31#define __SIZEOF_PTHREAD_BARRIER_T 20
32#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
33
34/* Data structure for mutex handling. */
35#define __PTHREAD_COMPAT_PADDING_MID
36#define __PTHREAD_COMPAT_PADDING_END
37#define __PTHREAD_MUTEX_LOCK_ELISION 0
38#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
39#define __PTHREAD_MUTEX_USE_UNION 1
40
41#define __LOCK_ALIGNMENT __attribute__ ((__aligned__ (4)))
42#define __ONCE_ALIGNMENT __attribute__ ((__aligned__ (4)))
43
44struct __pthread_rwlock_arch_t
45{
46 unsigned int __readers __attribute__ ((__aligned__ (4)));
47 unsigned int __writers;
48 unsigned int __wrphase_futex;
49 unsigned int __writers_futex;
50 unsigned int __pad3;
51 unsigned int __pad4;
52 unsigned char __pad1;
53 unsigned char __pad2;
54 unsigned char __shared;
55 /* FLAGS must stay at this position in the structure to maintain
56 binary compatibility. */
57 unsigned char __flags;
58 int __cur_writer;
59};
60
61#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
62
63#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/m68k/start.S created+120
...@@ -0,0 +1,120 @@
1/* Startup code compliant to the ELF m68k ABI.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* This is the canonical entry point, usually the first thing in the text
37 segment. The SVR4/m68k ABI says that when the entry point runs,
38 most registers' values are unspecified, except for:
39
40 %a1 Contains a function pointer to be registered with `atexit'.
41 This is how the dynamic linker arranges to have DT_FINI
42 functions called for shared libraries that have been loaded
43 before this code runs.
44
45 %sp The stack contains the arguments and environment:
46 0(%sp) argc
47 4(%sp) argv[0]
48 ...
49 (4*argc)(%sp) NULL
50 (4*(argc+1))(%sp) envp[0]
51 ...
52 NULL
53*/
54
55#include <sysdep.h>
56
57 .text
58 .globl _start
59 .type _start,@function
60_start:
61 /* Clear the frame pointer. The ABI suggests this be done, to mark
62 the outermost frame obviously. */
63 sub.l %fp, %fp
64
65 /* Extract the arguments as encoded on the stack and set up the
66 arguments for `main': argc, argv. envp will be determined
67 later in __libc_start_main. */
68 move.l (%sp)+, %d0 /* Pop the argument count. */
69 move.l %sp, %a0 /* The argument vector starts just at the
70 current stack top. */
71
72 /* Provide the highest stack address to the user code (for stacks
73 which grow downward). */
74 pea (%sp)
75
76 pea (%a1) /* Push address of the shared library
77 termination function. */
78
79#ifdef PIC
80 /* Load PIC register. */
81 LOAD_GOT (%a5)
82
83 /* Push the address of our own entry points to `.fini' and
84 `.init'. */
85 move.l __libc_csu_fini@GOT(%a5), -(%sp)
86 move.l __libc_csu_init@GOT(%a5), -(%sp)
87
88 pea (%a0) /* Push second argument: argv. */
89 move.l %d0, -(%sp) /* Push first argument: argc. */
90
91 move.l main@GOT(%a5), -(%sp)
92
93 /* Call the user's main function, and exit with its value. But
94 let the libc call main. */
95 jbsr __libc_start_main@PLTPC
96#else
97 /* Push the address of our own entry points to `.fini' and
98 `.init'. */
99 pea __libc_csu_fini
100 pea __libc_csu_init
101
102 pea (%a0) /* Push second argument: argv. */
103 move.l %d0, -(%sp) /* Push first argument: argc. */
104
105 pea main
106
107 /* Call the user's main function, and exit with its value. But
108 let the libc call main. */
109 jbsr __libc_start_main
110#endif
111
112 illegal /* Crash if somehow `exit' does return. */
113
114/* Define a symbol for the first piece of initialized data. */
115 .data
116 .globl __data_start
117__data_start:
118 .long 0
119 .weak data_start
120 data_start = __data_start
libc/glibc/sysdeps/m68k/symbol-hacks.h created+21
...@@ -0,0 +1,21 @@
1/* Hacks needed for symbol manipulation. m68k version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
20
21#include_next "symbol-hacks.h"
libc/glibc/sysdeps/m68k/sysdep.h created+74
...@@ -0,0 +1,74 @@
1/* Assembler macros for m68k.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Define an entry point visible from C.
24
25 There is currently a bug in gdb which prevents us from specifying
26 incomplete stabs information. Fake some entries here which specify
27 the current source file. */
28# define ENTRY(name) \
29 .globl C_SYMBOL_NAME(name); \
30 .type C_SYMBOL_NAME(name),@function; \
31 .p2align 2; \
32 C_LABEL(name) \
33 cfi_startproc; \
34 CALL_MCOUNT
35
36# undef END
37# define END(name) \
38 cfi_endproc; \
39 .size name,.-name
40
41
42/* If compiled for profiling, call `_mcount' at the start of each function. */
43# ifdef PROF
44/* The mcount code relies on a normal frame pointer being on the stack
45 to locate our caller, so push one just for its benefit. */
46# define CALL_MCOUNT \
47 move.l %fp, -(%sp); \
48 cfi_adjust_cfa_offset (4); cfi_rel_offset (%a6, 0); \
49 move.l %sp, %fp; \
50 jbsr JUMPTARGET (_mcount); \
51 move.l (%sp)+, %fp; \
52 cfi_adjust_cfa_offset (-4); cfi_restore (%a6);
53# else
54# define CALL_MCOUNT /* Do nothing. */
55# endif
56
57# define PSEUDO(name, syscall_name, args) \
58 .globl __syscall_error; \
59 ENTRY (name) \
60 DO_CALL (syscall_name, args); \
61 jcc JUMPTARGET(__syscall_error)
62
63# undef PSEUDO_END
64# define PSEUDO_END(name) \
65 END (name)
66
67# undef JUMPTARGET
68# ifdef PIC
69# define JUMPTARGET(name) name##@PLTPC
70# else
71# define JUMPTARGET(name) name
72# endif
73
74#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/mach/hurd/bits/stat.h created+263
...@@ -0,0 +1,263 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <bits/types.h>
26
27/* NOTE: The size of this structure (32 ints) is known in
28 <hurd/hurd_types.defs>, since it is used in the `io_stat' RPC. MiG
29 does not cope at all well with the passed C structure not being of
30 the expected size. There are some filler words at the end to allow
31 for future expansion. To increase the size of the structure used
32 in the RPC and retain binary compatibility, we would need to assign
33 a new message number. */
34
35struct stat
36 {
37 int st_fstype; /* File system type. */
38 __fsid_t st_fsid; /* File system ID. */
39#define st_dev st_fsid
40
41#ifndef __USE_FILE_OFFSET64
42 __ino_t st_ino; /* File number. */
43#else
44 __ino64_t st_ino; /* File number. */
45#endif
46 unsigned int st_gen; /* To detect reuse of file numbers. */
47 __dev_t st_rdev; /* Device if special file. */
48 __mode_t st_mode; /* File mode. */
49 __nlink_t st_nlink; /* Number of links. */
50
51 __uid_t st_uid; /* Owner. */
52 __gid_t st_gid; /* Owning group. */
53
54#ifndef __USE_FILE_OFFSET64
55 __off_t st_size; /* Size in bytes. */
56#else
57 __off64_t st_size; /* Size in bytes. */
58#endif
59
60#ifdef __USE_XOPEN2K8
61 /* Nanosecond resolution timestamps are stored in a format
62 equivalent to 'struct timespec'. This is the type used
63 whenever possible but the Unix namespace rules do not allow the
64 identifier 'timespec' to appear in the <sys/stat.h> header.
65 Therefore we have to handle the use of this header in strictly
66 standard-compliant sources special. */
67 struct timespec st_atim; /* Time of last access. */
68 struct timespec st_mtim; /* Time of last modification. */
69 struct timespec st_ctim; /* Time of last status change. */
70# define st_atime st_atim.tv_sec /* Backward compatibility. */
71# define st_mtime st_mtim.tv_sec
72# define st_ctime st_ctim.tv_sec
73#else
74 __time_t st_atime; /* Time of last access. */
75 unsigned long int st_atimensec; /* Nscecs of last access. */
76 __time_t st_mtime; /* Time of last modification. */
77 unsigned long int st_mtimensec; /* Nsecs of last modification. */
78 __time_t st_ctime; /* Time of last status change. */
79 unsigned long int st_ctimensec; /* Nsecs of last status change. */
80#endif
81
82 __blksize_t st_blksize; /* Optimal size for I/O. */
83
84#ifndef __USE_FILE_OFFSET64
85 __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated.
86 Not related to `st_blksize'. */
87#else
88 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
89 Not related to `st_blksize'. */
90#endif
91
92 __uid_t st_author; /* File author. */
93
94 unsigned int st_flags; /* User-defined flags.
95 High 16 bits can be set only by root. */
96
97#ifndef __USE_FILE_OFFSET64
98# define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 12 : 11)
99#else
100# define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
101#endif
102 int st_spare[_SPARE_SIZE]; /* Room for future expansion. */
103#undef _SPARE_SIZE
104 };
105
106#ifdef __USE_LARGEFILE64
107struct stat64
108 {
109 int st_fstype; /* File system type. */
110 __fsid_t st_fsid; /* File system ID. */
111# define st_dev st_fsid
112
113 __ino64_t st_ino; /* File number. */
114 unsigned int st_gen; /* To detect reuse of file numbers. */
115 __dev_t st_rdev; /* Device if special file. */
116 __mode_t st_mode; /* File mode. */
117 __nlink_t st_nlink; /* Number of links. */
118
119 __uid_t st_uid; /* Owner. */
120 __gid_t st_gid; /* Owning group. */
121
122 __off64_t st_size; /* Size in bytes. */
123
124#ifdef __USE_XOPEN2K8
125 /* Nanosecond resolution timestamps are stored in a format
126 equivalent to 'struct timespec'. This is the type used
127 whenever possible but the Unix namespace rules do not allow the
128 identifier 'timespec' to appear in the <sys/stat.h> header.
129 Therefore we have to handle the use of this header in strictly
130 standard-compliant sources special. */
131 struct timespec st_atim; /* Time of last access. */
132 struct timespec st_mtim; /* Time of last modification. */
133 struct timespec st_ctim; /* Time of last status change. */
134#else
135 __time_t st_atime; /* Time of last access. */
136 unsigned long int st_atimensec; /* Nscecs of last access. */
137 __time_t st_mtime; /* Time of last modification. */
138 unsigned long int st_mtimensec; /* Nsecs of last modification. */
139 __time_t st_ctime; /* Time of last status change. */
140 unsigned long int st_ctimensec; /* Nsecs of last status change. */
141#endif
142
143 __blksize_t st_blksize; /* Optimal size for I/O. */
144
145 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
146 Not related to `st_blksize'. */
147
148 __uid_t st_author; /* File author. */
149
150 unsigned int st_flags; /* User-defined flags.
151 High 16 bits can be set only by root. */
152
153#define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
154 int st_spare[_SPARE_SIZE]; /* Room for future expansion. */
155#undef _SPARE_SIZE
156 };
157#endif
158
159/* Tell code we have these members. */
160#define _STATBUF_ST_BLKSIZE
161/* Nanosecond resolution time values are supported. */
162#define _STATBUF_ST_NSEC
163
164/* Encoding of the file mode. */
165
166#define __S_IFMT 0170000 /* These bits determine file type. */
167
168/* File types. */
169#define __S_IFDIR 0040000 /* Directory. */
170#define __S_IFCHR 0020000 /* Character device. */
171#define __S_IFBLK 0060000 /* Block device. */
172#define __S_IFREG 0100000 /* Regular file. */
173#define __S_IFLNK 0120000 /* Symbolic link. */
174#define __S_IFSOCK 0140000 /* Socket. */
175#define __S_IFIFO 0010000 /* FIFO. */
176
177/* POSIX.1b objects. */
178#define __S_TYPEISMQ(buf) (0)
179#define __S_TYPEISSEM(buf) (0)
180#define __S_TYPEISSHM(buf) (0)
181
182/* Protection bits. */
183
184#define __S_ISUID 04000 /* Set user ID on execution. */
185#define __S_ISGID 02000 /* Set group ID on execution. */
186#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
187#define __S_IREAD 00400 /* Read by owner. */
188#define __S_IWRITE 00200 /* Write by owner. */
189#define __S_IEXEC 00100 /* Execute by owner. */
190
191
192#ifdef __USE_GNU
193/* If set, there is no benefit in caching the contents of this file. */
194#define S_INOCACHE 000000200000
195
196/* If the S_IUSEUNK bit is set, then the S_IUNKNOWN bits (see below)
197 control access for unknown users. If S_IUSEUNK is clear, then unknown
198 users are treated as "others" for purposes of access control. */
199#define S_IUSEUNK 000000400000
200/* Mask of protection bits for unknown users (no effective IDs at all). */
201#define S_IUNKNOWN 000007000000
202/* Shift S_IREAD, S_IWRITE, S_IEXEC left this many bits to produce the
203 protection bits for unknown users. */
204#define S_IUNKSHIFT 12
205
206/* Read only bits: */
207
208/* There is a passive translator set for this file */
209#define S_IPTRANS 000010000000
210/* There is an active translator running on this file */
211#define S_IATRANS 000020000000
212/* This is the root of a filesystem (or single node translator) */
213#define S_IROOT 000040000000
214/* All the bits relevant to translators */
215#define S_ITRANS 000070000000
216
217/* Definitely no mmaps to this. */
218#define S_IMMAP0 000100000000
219
220/* ALL the unused bits. */
221#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0| \
222 S_IUSEUNK|S_IUNKNOWN|07777))
223#endif
224
225#ifdef __USE_MISC
226/* Default file creation mask (umask). */
227# define CMASK 0022
228
229/* Definitions of flags stored in file flags word. */
230
231/* Super-user and owner changeable flags. */
232# define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
233# define UF_NODUMP 0x00000001 /* do not dump file */
234# define UF_IMMUTABLE 0x00000002 /* file may not be changed */
235# define UF_APPEND 0x00000004 /* writes to file may only append */
236# define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
237# define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
238
239/* Super-user changeable flags. */
240# define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
241# define SF_ARCHIVED 0x00010000 /* file is archived */
242# define SF_IMMUTABLE 0x00020000 /* file may not be changed */
243# define SF_APPEND 0x00040000 /* writes to file may only append */
244# define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
245# define SF_SNAPSHOT 0x00200000 /* snapshot inode */
246
247__BEGIN_DECLS
248
249/* Set file flags for FILE to FLAGS. */
250extern int chflags (__const char *__file, unsigned long int __flags) __THROW;
251
252/* Set file flags of the file referred to by FD to FLAGS. */
253extern int fchflags (int __fd, unsigned long int __flags) __THROW;
254
255__END_DECLS
256#endif
257
258#ifdef __USE_ATFILE
259# define UTIME_NOW -1 /* corresponds to the current time */
260# define UTIME_OMIT -2 /* target time is omitted */
261#endif
262
263#endif /* bits/stat.h */
libc/glibc/sysdeps/mach/hurd/bits/typesizes.h created+68
...@@ -0,0 +1,68 @@
1/* bits/typesizes.h -- underlying types for *_t. Hurd version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29#define __DEV_T_TYPE __U32_TYPE
30#define __UID_T_TYPE __U32_TYPE
31#define __GID_T_TYPE __U32_TYPE
32#define __INO_T_TYPE __ULONGWORD_TYPE
33#define __INO64_T_TYPE __UQUAD_TYPE
34#define __MODE_T_TYPE __U32_TYPE
35#define __NLINK_T_TYPE __UWORD_TYPE
36#define __OFF_T_TYPE __SLONGWORD_TYPE
37#define __OFF64_T_TYPE __SQUAD_TYPE
38#define __PID_T_TYPE __S32_TYPE
39#define __RLIM_T_TYPE __ULONGWORD_TYPE
40#define __RLIM64_T_TYPE __UQUAD_TYPE
41#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
42#define __BLKCNT64_T_TYPE __SQUAD_TYPE
43#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
44#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
45#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
46#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
47#define __FSWORD_T_TYPE __SWORD_TYPE
48#define __ID_T_TYPE __U32_TYPE
49#define __CLOCK_T_TYPE __SLONGWORD_TYPE
50#define __TIME_T_TYPE __SLONGWORD_TYPE
51#define __USECONDS_T_TYPE __U32_TYPE
52#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
53#define __DADDR_T_TYPE __S32_TYPE
54#define __KEY_T_TYPE __S32_TYPE
55#define __CLOCKID_T_TYPE __S32_TYPE
56#define __TIMER_T_TYPE __S32_TYPE
57#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
58#define __FSID_T_TYPE __UQUAD_TYPE
59#define __SSIZE_T_TYPE __SWORD_TYPE
60#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
61#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
62#define __CPU_MASK_TYPE __ULONGWORD_TYPE
63
64/* Number of descriptors that can fit in an `fd_set'. */
65#define __FD_SETSIZE 256
66
67
68#endif /* bits/typesizes.h */
libc/glibc/sysdeps/mach/hurd/dl-sysdep.h created+31
...@@ -0,0 +1,31 @@
1/* System-specific settings for dynamic linker code. Hurd version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* The private errno doesn't make sense on the Hurd. errno is always the
20 thread-local slot shared with libc, and it matters to share the cell
21 with libc because after startup we use libc functions that set errno
22 (open, mmap, etc). */
23
24#define RTLD_PRIVATE_ERRNO 0
25
26#ifdef SHARED
27/* _dl_argv and __libc_stack_end cannot be attribute_relro, because the stack-switching
28 libc initializer for using cthreads might write into it. */
29# define DL_ARGV_NOT_RELRO 1
30# define LIBC_STACK_END_NOT_RELRO 1
31#endif
libc/glibc/sysdeps/mach/hurd/kernel-features.h created+21
...@@ -0,0 +1,21 @@
1/* Set flags signalling availability of certain operating system features.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This file can define __ASSUME_* macros checked by certain source files.
20 Almost none of these are used outside of sysdeps/unix/sysv/linux code.
21 But those referring to POSIX-level features like O_* flags can be. */
libc/glibc/sysdeps/mach/i386/sysdep.h created+69
...@@ -0,0 +1,69 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MACH_I386_SYSDEP_H
20#define _MACH_I386_SYSDEP_H 1
21
22/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
23#include <dl-sysdep.h>
24#include <tls.h>
25
26#define LOSE asm volatile ("hlt")
27
28#define SNARF_ARGS(entry_sp, argc, argv, envp) \
29 do \
30 { \
31 char **p; \
32 argc = (int) *entry_sp; \
33 argv = (char **) (entry_sp + 1); \
34 p = argv; \
35 while (*p++ != NULL) \
36 ; \
37 if (p >= (char **) argv[0]) \
38 --p; \
39 envp = p; \
40 } while (0)
41
42#define CALL_WITH_SP(fn, info, sp) \
43 do { \
44 void **ptr = (void **) sp; \
45 *--(__typeof (info) *) ptr = info; \
46 ptr[-1] = ptr; \
47 --ptr; \
48 asm volatile ("movl %0, %%esp; call %1" : : \
49 "g" (ptr), "m" (*(long int *) (fn)) : "%esp"); \
50 } while (0)
51
52#define RETURN_TO(sp, pc, retval) \
53 asm volatile ("movl %0, %%esp; jmp %*%1 # %2" \
54 : : "g" (sp), "r" (pc), "a" (retval))
55
56
57#define STACK_GROWTH_DOWN
58
59/* Get the machine-independent Mach definitions. */
60#include <sysdeps/mach/sysdep.h>
61
62
63/* This should be rearranged, but at the moment this file provides
64 the most useful definitions for assembler syntax details. */
65#undef ENTRY
66#undef ALIGN
67#include <sysdeps/unix/i386/sysdep.h>
68
69#endif /* mach/i386/sysdep.h */
libc/glibc/sysdeps/mach/libc-lock.h created+230
...@@ -0,0 +1,230 @@
1/* libc-internal interface for mutex locks. Mach cthreads version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC_LOCK_H
20#define _LIBC_LOCK_H 1
21
22#ifdef _LIBC
23
24#include <tls.h>
25#include <lowlevellock.h>
26
27/* The locking here is very inexpensive, even for inlining. */
28#define _IO_lock_inexpensive 1
29
30typedef unsigned int __libc_lock_t;
31typedef struct
32{
33 __libc_lock_t lock;
34 int cnt;
35 void *owner;
36} __libc_lock_recursive_t;
37
38typedef __libc_lock_recursive_t __rtld_lock_recursive_t;
39
40extern char __libc_lock_self0[0];
41#define __libc_lock_owner_self() \
42 (__LIBC_NO_TLS () ? (void *)&__libc_lock_self0 : THREAD_SELF)
43
44#else
45typedef struct __libc_lock_opaque__ __libc_lock_t;
46typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
47#endif
48
49/* Define a lock variable NAME with storage class CLASS. The lock must be
50 initialized with __libc_lock_init before it can be used (or define it
51 with __libc_lock_define_initialized, below). Use `extern' for CLASS to
52 declare a lock defined in another module. In public structure
53 definitions you must use a pointer to the lock structure (i.e., NAME
54 begins with a `*'), because its storage size will not be known outside
55 of libc. */
56#define __libc_lock_define(CLASS,NAME) \
57 CLASS __libc_lock_t NAME;
58
59/* Define an initialized lock variable NAME with storage class CLASS. */
60#define _LIBC_LOCK_INITIALIZER LLL_INITIALIZER
61#define __libc_lock_define_initialized(CLASS,NAME) \
62 CLASS __libc_lock_t NAME = LLL_INITIALIZER;
63
64/* Initialize the named lock variable, leaving it in a consistent, unlocked
65 state. */
66#define __libc_lock_init(NAME) (NAME) = LLL_INITIALIZER
67
68/* Finalize the named lock variable, which must be locked. It cannot be
69 used again until __libc_lock_init is called again on it. This must be
70 called on a lock variable before the containing storage is reused. */
71#define __libc_lock_fini __libc_lock_unlock
72#define __libc_lock_fini_recursive __libc_lock_unlock_recursive
73#define __rtld_lock_fini_recursive __rtld_lock_unlock_recursive
74
75/* Lock the named lock variable. */
76#define __libc_lock_lock(NAME) \
77 ({ lll_lock (&(NAME), 0); 0; })
78
79/* Lock the named lock variable. */
80#define __libc_lock_trylock(NAME) lll_trylock (&(NAME))
81
82/* Unlock the named lock variable. */
83#define __libc_lock_unlock(NAME) \
84 ({ lll_unlock (&(NAME), 0); 0; })
85
86#define __libc_lock_define_recursive(CLASS,NAME) \
87 CLASS __libc_lock_recursive_t NAME;
88
89#define _LIBC_LOCK_RECURSIVE_INITIALIZER { LLL_INITIALIZER, 0, 0 }
90
91#define __libc_lock_define_initialized_recursive(CLASS,NAME) \
92 CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
93
94#define __rtld_lock_define_recursive(CLASS,NAME) \
95 __libc_lock_define_recursive (CLASS, NAME)
96#define _RTLD_LOCK_RECURSIVE_INITIALIZER \
97 _LIBC_LOCK_RECURSIVE_INITIALIZER
98#define __rtld_lock_define_initialized_recursive(CLASS,NAME) \
99 __libc_lock_define_initialized_recursive (CLASS, NAME)
100
101#define __libc_lock_init_recursive(NAME) \
102 ({ \
103 (NAME) = (__libc_lock_recursive_t)_LIBC_LOCK_RECURSIVE_INITIALIZER; \
104 0; \
105 })
106
107#define __libc_lock_trylock_recursive(NAME) \
108 ({ \
109 __libc_lock_recursive_t *const __lock = &(NAME); \
110 void *__self = __libc_lock_owner_self (); \
111 int __r = 0; \
112 if (__self == __lock->owner) \
113 ++__lock->cnt; \
114 else if ((__r = lll_trylock (&__lock->lock)) == 0) \
115 __lock->owner = __self, __lock->cnt = 1; \
116 __r; \
117 })
118
119#define __libc_lock_lock_recursive(NAME) \
120 ({ \
121 __libc_lock_recursive_t *const __lock = &(NAME); \
122 void *__self = __libc_lock_owner_self (); \
123 if (__self != __lock->owner) \
124 { \
125 lll_lock (&__lock->lock, 0); \
126 __lock->owner = __self; \
127 } \
128 ++__lock->cnt; \
129 (void)0; \
130 })
131
132#define __libc_lock_unlock_recursive(NAME) \
133 ({ \
134 __libc_lock_recursive_t *const __lock = &(NAME); \
135 if (--__lock->cnt == 0) \
136 { \
137 __lock->owner = 0; \
138 lll_unlock (&__lock->lock, 0); \
139 } \
140 })
141
142
143#define __rtld_lock_initialize(NAME) \
144 (void) ((NAME) = (__rtld_lock_recursive_t) _RTLD_LOCK_RECURSIVE_INITIALIZER)
145#define __rtld_lock_trylock_recursive(NAME) \
146 __libc_lock_trylock_recursive (NAME)
147#define __rtld_lock_lock_recursive(NAME) \
148 __libc_lock_lock_recursive(NAME)
149#define __rtld_lock_unlock_recursive(NAME) \
150 __libc_lock_unlock_recursive (NAME)
151
152/* XXX for now */
153#define __libc_rwlock_define __libc_lock_define
154#define __libc_rwlock_define_initialized __libc_lock_define_initialized
155#define __libc_rwlock_init __libc_lock_init
156#define __libc_rwlock_fini __libc_lock_fini
157#define __libc_rwlock_rdlock __libc_lock_lock
158#define __libc_rwlock_wrlock __libc_lock_lock
159#define __libc_rwlock_tryrdlock __libc_lock_trylock
160#define __libc_rwlock_trywrlock __libc_lock_trylock
161#define __libc_rwlock_unlock __libc_lock_unlock
162
163struct __libc_cleanup_frame
164{
165 void (*__fct) (void *);
166 void *__argp;
167 int __doit;
168};
169
170__extern_inline void
171__libc_cleanup_fct (struct __libc_cleanup_frame *framep)
172{
173 if (framep->__doit)
174 framep->__fct (framep->__argp);
175}
176
177/* Start a critical region with a cleanup function */
178#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
179 do \
180 { \
181 struct __libc_cleanup_frame __cleanup \
182 __attribute__ ((__cleanup__ (__libc_cleanup_fct))) = \
183 { .__fct = (FCT), .__argp = (ARG), .__doit = (DOIT) };
184
185/* This one closes the brace above. */
186#define __libc_cleanup_region_end(DOIT) \
187 __cleanup.__doit = (DOIT); \
188 } \
189 while (0)
190
191#define __libc_cleanup_end(DOIT) __cleanup.__doit = (DOIT);
192
193#define __libc_cleanup_push(fct, arg) __libc_cleanup_region_start (1, fct, arg)
194#define __libc_cleanup_pop(execute) __libc_cleanup_region_end (execute)
195
196/* Use mutexes as once control variables. */
197
198struct __libc_once
199 {
200 __libc_lock_t lock;
201 int done;
202 };
203
204#define __libc_once_define(CLASS,NAME) \
205 CLASS struct __libc_once NAME = { _LIBC_LOCK_INITIALIZER, 0 }
206
207/* Call handler iff the first call. */
208#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
209 do { \
210 __libc_lock_lock (ONCE_CONTROL.lock); \
211 if (!ONCE_CONTROL.done) \
212 (INIT_FUNCTION) (); \
213 ONCE_CONTROL.done = 1; \
214 __libc_lock_unlock (ONCE_CONTROL.lock); \
215 } while (0)
216
217/* Get once control variable. */
218#define __libc_once_get(ONCE_CONTROL) ((ONCE_CONTROL).done != 0)
219
220#ifdef _LIBC
221/* We need portable names for some functions. E.g., when they are
222 used as argument to __libc_cleanup_region_start. */
223#define __libc_mutex_unlock __libc_lock_unlock
224
225/* Hide the definitions which are only supposed to be used inside libc in
226 a separate file. This file is not present in the installation! */
227# include <libc-lockP.h>
228#endif
229
230#endif /* libc-lock.h */
libc/glibc/sysdeps/mach/sys/syscall.h created+1
...@@ -0,0 +1 @@
1/* The Mach syscalls are in <mach/syscall_sw.h>. */
libc/glibc/sysdeps/mach/sysdep.h created+86
...@@ -0,0 +1,86 @@
1/* Copyright (C) 1994-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifdef __ASSEMBLER__
19
20/* Get the Mach definitions of ENTRY and kernel_trap. */
21#include <mach/machine/syscall_sw.h>
22
23/* The Mach definitions assume underscores should be prepended to
24 symbol names. Redefine them to do so only when appropriate. */
25#undef EXT
26#undef LEXT
27#define EXT(x) C_SYMBOL_NAME(x)
28#define LEXT(x) C_SYMBOL_NAME(x##:)
29
30/* For ELF we need to add the `.type' directive to make shared libraries
31 work right. */
32#undef ENTRY
33#define ENTRY(name) \
34 .globl name; \
35 .align ALIGN; \
36 .type name,@function; \
37 name:
38
39#endif
40
41/* This is invoked by things run when there is random lossage, before they
42 try to do anything else. Just to be safe, deallocate the reply port so
43 bogons arriving on it don't foul up future RPCs. */
44
45#ifndef __ASSEMBLER__
46#define FATAL_PREPARE_INCLUDE <mach/mig_support.h>
47#define FATAL_PREPARE __mig_dealloc_reply_port (MACH_PORT_NULL)
48#endif
49
50/* sysdeps/mach/MACHINE/sysdep.h should define the following macros. */
51
52/* Produce a text assembler label for the C global symbol NAME. */
53#ifndef ENTRY
54#define ENTRY(name) .error ENTRY not defined by sysdeps/mach/MACHINE/sysdep.h
55/* This is not used on all machines. */
56#endif
57
58/* Set variables ARGC, ARGV, and ENVP for the arguments
59 left on the stack by the microkernel. */
60#ifndef SNARF_ARGS
61#define SNARF_ARGS(argc, argv, envp)
62#error SNARF_ARGS not defined by sysdeps/mach/MACHINE/sysdep.h
63#endif
64
65/* Call the C function FN with no arguments,
66 on a stack starting at SP (as returned by *_cthread_init_routine).
67 You don't need to deal with FN returning; it shouldn't. */
68#ifndef CALL_WITH_SP
69#define CALL_WITH_SP(fn, sp)
70#error CALL_WITH_SP not defined by sysdeps/mach/MACHINE/sysdep.h
71#endif
72
73/* LOSE can be defined as the `halt' instruction or something
74 similar which will cause the process to die in a characteristic
75 way suggesting a bug. */
76#ifndef LOSE
77#define LOSE ({ volatile int zero = 0; zero / zero; })
78#endif
79
80/* One of these should be defined to specify the stack direction. */
81#if !defined (STACK_GROWTH_UP) && !defined (STACK_GROWTH_DOWN)
82#error stack direction unspecified
83#endif
84
85/* Used by some assembly code. */
86#define C_SYMBOL_NAME(name) name
libc/glibc/sysdeps/microblaze/bits/endian.h created+30
...@@ -0,0 +1,30 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ENDIAN_H
20# error "Never use <bits/endian.h> directly; include <endian.h> instead."
21#endif
22
23/* MicroBlaze can be either big or little endian. */
24#ifdef _BIG_ENDIAN
25# define __BYTE_ORDER __BIG_ENDIAN
26# define __FLOAT_WORD_ORDER __BIG_ENDIAN
27#else
28# define __BYTE_ORDER __LITTLE_ENDIAN
29# define __FLOAT_WORD_ORDER __LITTLE_ENDIAN
30#endif
libc/glibc/sysdeps/microblaze/crti.S created+90
...@@ -0,0 +1,90 @@
1/* Special .init and .fini section support for MicroBlaze.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 addik r1,r1,-32
65 swi r20,r1,28
66 mfs r20,rpc
67 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
68 lwi r3,r20,PREINIT_FUNCTION@GOT
69#if PREINIT_FUNCTION_WEAK
70 beqid r3,$Lno_weak_fn:
71 swi r15,r1,0
72 brlid r15,PREINIT_FUNCTION@PLT
73$Lno_weak_fn:
74#else
75 swi r15,r1,0
76 brald r15,r3
77#endif
78 nop # Unfilled delay slot
79
80 .section .fini,"ax",@progbits
81 .align 2
82 .globl _fini
83 .hidden _fini
84 .type _fini, @function
85_fini:
86 addik r1,r1,-32
87 swi r20,r1,28
88 swi r15,r1,0
89 mfs r20,rpc
90 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
libc/glibc/sysdeps/microblaze/crtn.S created+51
...@@ -0,0 +1,51 @@
1/* Special .init and .fini section support for MicroBlaze.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 lwi r15,r1,0
43 lwi r20,r1,28
44 rtsd r15,8
45 addik r1,r1,32
46
47 .section .fini,"ax",@progbits
48 lwi r15,r1,0
49 lwi r20,r1,28
50 rtsd r15,8
51 addik r1,r1,32
libc/glibc/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h created+72
...@@ -0,0 +1,72 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20# define _BITS_PTHREADTYPES_ARCH_H 1
21
22# include <endian.h>
23
24# define __SIZEOF_PTHREAD_ATTR_T 36
25# define __SIZEOF_PTHREAD_MUTEX_T 24
26# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
27# define __SIZEOF_PTHREAD_COND_T 48
28# define __SIZEOF_PTHREAD_CONDATTR_T 4
29# define __SIZEOF_PTHREAD_RWLOCK_T 32
30# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
31# define __SIZEOF_PTHREAD_BARRIER_T 20
32# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
33
34/* Definitions for internal mutex struct. */
35#define __PTHREAD_COMPAT_PADDING_MID
36#define __PTHREAD_COMPAT_PADDING_END
37#define __PTHREAD_MUTEX_LOCK_ELISION 0
38#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
39#define __PTHREAD_MUTEX_USE_UNION 1
40
41#define __LOCK_ALIGNMENT
42#define __ONCE_ALIGNMENT
43
44struct __pthread_rwlock_arch_t
45{
46 unsigned int __readers;
47 unsigned int __writers;
48 unsigned int __wrphase_futex;
49 unsigned int __writers_futex;
50 unsigned int __pad3;
51 unsigned int __pad4;
52# if __BYTE_ORDER == __BIG_ENDIAN
53 unsigned char __pad1;
54 unsigned char __pad2;
55 unsigned char __shared;
56 /* FLAGS must stay at this position in the structure to maintain
57 binary compatibility. */
58 unsigned char __flags;
59# else
60 /* FLAGS must stay at this position in the structure to maintain
61 binary compatibility. */
62 unsigned char __flags;
63 unsigned char __shared;
64 unsigned char __pad1;
65 unsigned char __pad2;
66# endif
67 int __cur_writer;
68};
69
70# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
71
72#endif /* bits/pthreadtypes.h. */
libc/glibc/sysdeps/microblaze/start.S created+84
...@@ -0,0 +1,84 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36 .text
37 .globl _start
38 .type _start,@function
39_start:
40 /* On entry the stack contains the following args:
41 r1+0 - argc
42 r1+4 - argv[0]
43 ...
44 r1+4*(argc-1) - argv[argc-1]
45 r1+4*argc - NULL
46 r1+4*argc + 4 - envp[0]
47 ...
48 NULL
49 */
50 addk r3,r0,r0
51 addk r5,r1,r0
521:
53 addik r5,r5,4
54 lw r4,r5,r0
55 bneid r4,1b
56 addik r3,r3,1
57 addik r6,r3,-1
58 sw r6,r1,r0
59 addik r7,r1,4
60 addik r1,r1,-24
61#ifdef SHARED
62 /* Setup PIC. */
63 mfs r20,rpc
64 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
65 lwi r5,r20,main@GOT
66 lwi r8,r20,__libc_csu_init@GOT
67 lwi r9,r20,__libc_csu_fini@GOT
68 brid __libc_start_main@PLT
69 addk r10,r0,r0
70#else
71 addik r5,r0,main
72 addik r8,r0,__libc_csu_init
73 addik r9,r0,__libc_csu_fini
74 brid __libc_start_main
75 addk r10,r0,r0
76#endif
77
78/* Define a symbol for the first piece of initialized data. */
79 .data
80 .globl __data_start
81__data_start:
82 .long 0
83 .weak data_start
84 data_start = __data_start
libc/glibc/sysdeps/microblaze/sysdep.h created+85
...@@ -0,0 +1,85 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Syntactic details of assembler. */
24
25# define ALIGNARG(log2) log2
26# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
27
28/* Define an entry point visible from C. */
29# define ENTRY(name) \
30 .globl C_SYMBOL_NAME(name); \
31 .type C_SYMBOL_NAME(name),@function; \
32 .align ALIGNARG(2); \
33 C_LABEL(name) \
34 CALL_MCOUNT
35
36# undef END
37# define END(name) ASM_SIZE_DIRECTIVE(name)
38
39
40/* If compiled for profiling, call `_mcount' at the start of each function. */
41# ifdef PROF
42/* The mcount code relies on a normal frame pointer being on the stack
43 to locate our caller, so push one just for its benefit. */
44# define CALL_MCOUNT \
45 addik r1,r1,-4; \
46 swi r15,r1,0; \
47 brlid r15,JUMPTARGET(mcount); \
48 nop; \
49 lwi r15,r1,0; \
50 addik r1,r1,4;
51# else
52# define CALL_MCOUNT /* Do nothing. */
53# endif
54
55/* Since C identifiers are not normally prefixed with an underscore
56 on this system, the asm identifier `syscall_error' intrudes on the
57 C name space. Make sure we use an innocuous name. */
58# define syscall_error __syscall_error
59# define mcount _mcount
60
61# define PSEUDO(name, syscall_name, args) \
62 .globl syscall_error; \
63 ENTRY (name) \
64 DO_CALL (syscall_name, args);
65
66# define ret \
67 rtsd r15,8; nop;
68
69# undef PSEUDO_END
70# define PSEUDO_END(name) \
71 END (name)
72
73# undef JUMPTARGET
74# ifdef PIC
75# define JUMPTARGET(name) name##@PLTPC
76# else
77# define JUMPTARGET(name) name
78# endif
79
80/* Local label name for asm code. */
81# ifndef L
82# define L(name) $L##name
83# endif
84
85# endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/mips/bits/endian.h created+15
...@@ -0,0 +1,15 @@
1/* The MIPS architecture has selectable endianness.
2 It exists in both little and big endian flavours and we
3 want to be able to share the installed header files between
4 both, so we define __BYTE_ORDER based on GCC's predefines. */
5
6#ifndef _ENDIAN_H
7# error "Never use <bits/endian.h> directly; include <endian.h> instead."
8#endif
9
10#ifdef __MIPSEB
11# define __BYTE_ORDER __BIG_ENDIAN
12#endif
13#ifdef __MIPSEL
14# define __BYTE_ORDER __LITTLE_ENDIAN
15#endif
libc/glibc/sysdeps/mips/dl-dtprocnum.h created+21
...@@ -0,0 +1,21 @@
1/* Configuration of lookup functions. MIPS version.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Number of extra dynamic section entries for this architecture. By
20 default there are none. */
21#define DT_THISPROCNUM DT_MIPS_NUM
libc/glibc/sysdeps/mips/mips32/crti.S created+102
...@@ -0,0 +1,102 @@
1/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 .set noreorder
72 .cpload $25
73 .set reorder
74 addiu $sp,$sp,-32
75 .cprestore 16
76 sw $31,28($sp)
77#if PREINIT_FUNCTION_WEAK
78 lw $2,%got(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 lw $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 lw $25,%got(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 .set noreorder
98 .cpload $25
99 .set reorder
100 addiu $sp,$sp,-32
101 .cprestore 16
102 sw $31,28($sp)
libc/glibc/sysdeps/mips/mips32/crtn.S created+57
...@@ -0,0 +1,57 @@
1/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 lw $31,28($sp)
43 .set noreorder
44 .set nomacro
45 j $31
46 addiu $sp,$sp,32
47 .set macro
48 .set reorder
49
50 .section .fini,"ax",@progbits
51 lw $31,28($sp)
52 .set noreorder
53 .set nomacro
54 j $31
55 addiu $sp,$sp,32
56 .set macro
57 .set reorder
libc/glibc/sysdeps/mips/mips64/n32/crti.S created+102
...@@ -0,0 +1,102 @@
1/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 addiu $sp,$sp,-16
72 sd $28,0($sp)
73 lui $28,%hi(%neg(%gp_rel(_init)))
74 addu $28,$28,$25
75 sd $31,8($sp)
76 addiu $28,$28,%lo(%neg(%gp_rel(_init)))
77#if PREINIT_FUNCTION_WEAK
78 lw $2,%got_disp(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 lw $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 lw $25,%got_disp(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 addiu $sp,$sp,-16
98 sd $28,0($sp)
99 lui $28,%hi(%neg(%gp_rel(_fini)))
100 addu $28,$28,$25
101 sd $31,8($sp)
102 addiu $28,$28,%lo(%neg(%gp_rel(_fini)))
libc/glibc/sysdeps/mips/mips64/n32/crtn.S created+59
...@@ -0,0 +1,59 @@
1/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 ld $31,8($sp)
43 ld $28,0($sp)
44 .set noreorder
45 .set nomacro
46 j $31
47 addiu $sp,$sp,16
48 .set macro
49 .set reorder
50
51 .section .fini,"ax",@progbits
52 ld $31,8($sp)
53 ld $28,0($sp)
54 .set noreorder
55 .set nomacro
56 j $31
57 addiu $sp,$sp,16
58 .set macro
59 .set reorder
libc/glibc/sysdeps/mips/mips64/n64/crti.S created+102
...@@ -0,0 +1,102 @@
1/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 daddiu $sp,$sp,-16
72 sd $28,0($sp)
73 lui $28,%hi(%neg(%gp_rel(_init)))
74 daddu $28,$28,$25
75 sd $31,8($sp)
76 daddiu $28,$28,%lo(%neg(%gp_rel(_init)))
77#if PREINIT_FUNCTION_WEAK
78 ld $2,%got_disp(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 ld $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 ld $25,%got_disp(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 daddiu $sp,$sp,-16
98 sd $28,0($sp)
99 lui $28,%hi(%neg(%gp_rel(_fini)))
100 daddu $28,$28,$25
101 sd $31,8($sp)
102 daddiu $28,$28,%lo(%neg(%gp_rel(_fini)))
libc/glibc/sysdeps/mips/mips64/n64/crtn.S created+59
...@@ -0,0 +1,59 @@
1/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 ld $31,8($sp)
43 ld $28,0($sp)
44 .set noreorder
45 .set nomacro
46 j $31
47 daddiu $sp,$sp,16
48 .set macro
49 .set reorder
50
51 .section .fini,"ax",@progbits
52 ld $31,8($sp)
53 ld $28,0($sp)
54 .set noreorder
55 .set nomacro
56 j $31
57 daddiu $sp,$sp,16
58 .set macro
59 .set reorder
libc/glibc/sysdeps/mips/nptl/bits/pthreadtypes-arch.h created+89
...@@ -0,0 +1,89 @@
1/* Machine-specific pthread type layouts. MIPS version.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <endian.h>
23
24#if _MIPS_SIM == _ABI64
25# define __SIZEOF_PTHREAD_ATTR_T 56
26# define __SIZEOF_PTHREAD_MUTEX_T 40
27# define __SIZEOF_PTHREAD_RWLOCK_T 56
28# define __SIZEOF_PTHREAD_BARRIER_T 32
29#else
30# define __SIZEOF_PTHREAD_ATTR_T 36
31# define __SIZEOF_PTHREAD_MUTEX_T 24
32# define __SIZEOF_PTHREAD_RWLOCK_T 32
33# define __SIZEOF_PTHREAD_BARRIER_T 20
34#endif
35#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
36#define __SIZEOF_PTHREAD_COND_T 48
37#define __SIZEOF_PTHREAD_CONDATTR_T 4
38#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
39#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
40
41/* Data structure for mutex handling. */
42#define __PTHREAD_COMPAT_PADDING_MID
43#define __PTHREAD_COMPAT_PADDING_END
44#define __PTHREAD_MUTEX_LOCK_ELISION 0
45#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (_MIPS_SIM != _ABI64)
46#define __PTHREAD_MUTEX_USE_UNION (_MIPS_SIM != _ABI64)
47
48#define __LOCK_ALIGNMENT
49#define __ONCE_ALIGNMENT
50
51struct __pthread_rwlock_arch_t
52{
53 unsigned int __readers;
54 unsigned int __writers;
55 unsigned int __wrphase_futex;
56 unsigned int __writers_futex;
57 unsigned int __pad3;
58 unsigned int __pad4;
59#if _MIPS_SIM == _ABI64
60 int __cur_writer;
61 int __shared;
62 unsigned long int __pad1;
63 unsigned long int __pad2;
64 /* FLAGS must stay at this position in the structure to maintain
65 binary compatibility. */
66 unsigned int __flags;
67# else
68# if __BYTE_ORDER == __BIG_ENDIAN
69 unsigned char __pad1;
70 unsigned char __pad2;
71 unsigned char __shared;
72 /* FLAGS must stay at this position in the structure to maintain
73 binary compatibility. */
74 unsigned char __flags;
75# else
76 /* FLAGS must stay at this position in the structure to maintain
77 binary compatibility. */
78 unsigned char __flags;
79 unsigned char __shared;
80 unsigned char __pad1;
81 unsigned char __pad2;
82# endif
83 int __cur_writer;
84#endif
85};
86
87#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
88
89#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/mips/start.S created+185
...@@ -0,0 +1,185 @@
1/* Startup code compliant to the ELF Mips ABI.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36#define __ASSEMBLY__ 1
37#include <entry.h>
38#include <sgidefs.h>
39#include <sys/asm.h>
40
41#ifndef ENTRY_POINT
42#error ENTRY_POINT needs to be defined for start.S on MIPS/ELF.
43#endif
44
45/* This is the canonical entry point, usually the first thing in the text
46 segment. The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
47 point runs, most registers' values are unspecified, except for:
48
49 v0 ($2) Contains a function pointer to be registered with `atexit'.
50 This is how the dynamic linker arranges to have DT_FINI
51 functions called for shared libraries that have been loaded
52 before this code runs.
53
54 sp ($29) The stack contains the arguments and environment:
55 0(%esp) argc
56 4(%esp) argv[0]
57 ...
58 (4*argc)(%esp) NULL
59 (4*(argc+1))(%esp) envp[0]
60 ...
61 NULL
62 ra ($31) The return address register is set to zero so that programs
63 that search backword through stack frames recognize the last
64 stack frame.
65*/
66
67
68/* We need to call:
69 __libc_start_main (int (*main) (int, char **, char **), int argc,
70 char **argv, void (*init) (void), void (*fini) (void),
71 void (*rtld_fini) (void), void *stack_end)
72*/
73
74 .text
75 .globl ENTRY_POINT
76 .type ENTRY_POINT,@function
77#ifndef __mips16
78ENTRY_POINT:
79# ifdef __PIC__
80 SETUP_GPX($0)
81 SETUP_GPX64($25,$0)
82# else
83 PTR_LA $28, _gp /* Setup GP correctly if we're non-PIC. */
84 move $31, $0
85# endif
86
87 PTR_LA $4, main /* main */
88 PTR_L $5, 0($29) /* argc */
89 PTR_ADDIU $6, $29, PTRSIZE /* argv */
90
91 /* Allocate space on the stack for seven arguments (o32 only)
92 and make sure the stack is aligned to double words (8 bytes)
93 on o32 and quad words (16 bytes) on n32 and n64. */
94
95 and $29, -2 * SZREG
96# if _MIPS_SIM == _ABIO32
97 PTR_SUBIU $29, 32
98# endif
99 PTR_LA $7, __libc_csu_init /* init */
100 PTR_LA $8, __libc_csu_fini
101# if _MIPS_SIM == _ABIO32
102 PTR_S $8, 16($29) /* fini */
103 PTR_S $2, 20($29) /* rtld_fini */
104 PTR_S $29, 24($29) /* stack_end */
105# else
106 move $9, $2 /* rtld_fini */
107 move $10, $29 /* stack_end */
108# endif
109 PTR_LA $25, __libc_start_main
110 jalr $25
111hlt: b hlt /* Crash if somehow it does return. */
112
113#elif _MIPS_SIM == _ABIO32 /* __mips16 */
114 /* MIPS16 entry point. */
115 .set mips16
116ENTRY_POINT:
117# ifdef __PIC__
118 li $3, %hi(_gp_disp)
119 addiu $4, $pc, %lo(_gp_disp)
120 sll $3, 16
121 addu $3, $4
122 move $gp, $3
123# else
124 li $3, %hi(_gp)
125 sll $3, 16
126 addiu $3, %lo(_gp)
127 move $gp, $3
128# endif
129 /* Tie end of stack frames. */
130 li $4, 0
131 move $31, $4
132 /* Create new SP value in $7, including alignment. */
133 li $4, 2 * SZREG
134 neg $4, $4
135 move $7, $sp
136 and $7, $4
137 addiu $7, -32
138 /* Load arguments with original SP. */
139 lw $5, 0($sp)
140 addiu $6, $sp, PTRSIZE
141 /* Update SP. */
142 move $sp, $7
143 /* Lay out last arguments, and call __libc_start_main(). */
144# ifdef __PIC__
145 sw $7, 24($sp) /* stack_end */
146 lw $4, %got(__libc_csu_fini)($3)
147 lw $7, %got(__libc_csu_init)($3) /* init */
148 sw $4, 16($sp) /* fini */
149 lw $4, %got(main)($3) /* main */
150 lw $3, %call16(__libc_start_main)($3)
151 sw $2, 20($sp) /* rtld_fini */
152 move $25, $3
153 jalr $3
154# else
155 lw $4, 1f
156 sw $7, 24($sp) /* stack_end */
157 lw $7, 2f /* init */
158 sw $4, 16($sp) /* fini */
159 lw $4, 3f /* main */
160 sw $2, 20($sp) /* rtld_fini */
161 /* Load and call __libc_start_main(). */
162 lw $3, 4f
163 jalr $3
164# endif
165hlt: b hlt /* Crash if somehow it does return. */
166# ifndef __PIC__
167 .align 2
1681: .word __libc_csu_fini
1692: .word __libc_csu_init
1703: .word main
1714: .word __libc_start_main
172# endif
173
174#else /* __mips16 && _MIPS_SIM != _ABIO32 */
175# error "MIPS16 support for N32/N64 not implemented"
176
177#endif /* __mips16 */
178
179/* Define a symbol for the first piece of initialized data. */
180 .data
181 .globl __data_start
182__data_start:
183 .long 0
184 .weak data_start
185 data_start = __data_start
libc/glibc/sysdeps/nios2/bits/endian.h created+12
...@@ -0,0 +1,12 @@
1/* The Nios II architecture has selectable endianness. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#ifdef __nios2_big_endian__
8# define __BYTE_ORDER __BIG_ENDIAN
9#endif
10#ifdef __nios2_little_endian__
11# define __BYTE_ORDER __LITTLE_ENDIAN
12#endif
libc/glibc/sysdeps/nios2/crti.S created+98
...@@ -0,0 +1,98 @@
1/* Special .init and .fini section support for Nios II.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifndef PREINIT_FUNCTION
44# define PREINIT_FUNCTION __gmon_start__
45#endif
46
47#ifndef PREINIT_FUNCTION_WEAK
48# define PREINIT_FUNCTION_WEAK 1
49#endif
50
51#if PREINIT_FUNCTION_WEAK
52 weak_extern (PREINIT_FUNCTION)
53#else
54 .hidden PREINIT_FUNCTION
55#endif
56
57 .section .init,"ax",@progbits
58 .align 2
59 .global _init
60 .hidden _init
61 .type _init, @function
62_init:
63 addi sp, sp, -8
64 stw r22, 0(sp)
65 nextpc r22
66 1:
67 movhi r8, %hiadj(_gp_got - 1b)
68 addi r8, r8, %lo(_gp_got - 1b)
69 add r22, r22, r8
70 stw ra, 4(sp)
71#if PREINIT_FUNCTION_WEAK
72 movhi r2, %got_hiadj(PREINIT_FUNCTION)
73 addi r2, r2, %got_lo(PREINIT_FUNCTION)
74 add r2, r2, r22
75 ldw r2, 0(r2)
76 beq r2, zero, .L5
77#endif
78 movhi r2, %call_hiadj(PREINIT_FUNCTION)
79 addi r2, r2, %call_lo(PREINIT_FUNCTION)
80 add r2, r2, r22
81 ldw r2, 0(r2)
82 callr r2
83.L5:
84
85 .section .fini,"ax",@progbits
86 .align 2
87 .global _fini
88 .hidden _fini
89 .type _fini, @function
90_fini:
91 addi sp, sp, -8
92 stw r22, 0(sp)
93 nextpc r22
94 1:
95 movhi r8, %hiadj(_gp_got - 1b)
96 addi r8, r8, %lo(_gp_got - 1b)
97 stw ra, 4(sp)
98 add r22, r22, r8
libc/glibc/sysdeps/nios2/crtn.S created+49
...@@ -0,0 +1,49 @@
1/* Special .init and .fini section support for Nios II.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 ldw ra, 4(sp)
41 ldw r22, 0(sp)
42 addi sp, sp, 8
43 ret
44
45 .section .fini,"ax",@progbits
46 ldw ra, 4(sp)
47 ldw r22, 0(sp)
48 addi sp, sp, 8
49 ret
libc/glibc/sysdeps/nios2/dl-sysdep.h created+25
...@@ -0,0 +1,25 @@
1/* System-specific settings for dynamic linker code. Nios II version.
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
24
25#define DL_EXTERN_PROTECTED_DATA
libc/glibc/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h created+72
...@@ -0,0 +1,72 @@
1/* Machine-specific pthread type layouts. Nios II version.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <endian.h>
23
24#define __SIZEOF_PTHREAD_ATTR_T 36
25#define __SIZEOF_PTHREAD_MUTEX_T 24
26#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
27#define __SIZEOF_PTHREAD_COND_T 48
28#define __SIZEOF_PTHREAD_CONDATTR_T 4
29#define __SIZEOF_PTHREAD_RWLOCK_T 32
30#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
31#define __SIZEOF_PTHREAD_BARRIER_T 20
32#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
33
34/* Data structure for mutex handling. */
35#define __PTHREAD_COMPAT_PADDING_MID
36#define __PTHREAD_COMPAT_PADDING_END
37#define __PTHREAD_MUTEX_LOCK_ELISION 0
38#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
39#define __PTHREAD_MUTEX_USE_UNION 1
40
41#define __LOCK_ALIGNMENT
42#define __ONCE_ALIGNMENT
43
44struct __pthread_rwlock_arch_t
45{
46 unsigned int __readers;
47 unsigned int __writers;
48 unsigned int __wrphase_futex;
49 unsigned int __writers_futex;
50 unsigned int __pad3;
51 unsigned int __pad4;
52#if __BYTE_ORDER == __BIG_ENDIAN
53 unsigned char __pad1;
54 unsigned char __pad2;
55 unsigned char __shared;
56 /* FLAGS must stay at this position in the structure to maintain
57 binary compatibility. */
58 unsigned char __flags;
59#else
60 /* FLAGS must stay at this position in the structure to maintain
61 binary compatibility. */
62 unsigned char __flags;
63 unsigned char __shared;
64 unsigned char __pad1;
65 unsigned char __pad2;
66#endif
67 int __cur_writer;
68};
69
70#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
71
72#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/nios2/start.S created+146
...@@ -0,0 +1,146 @@
1/* Startup code for Nios II
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* This is the canonical entry point, usually the first thing in the text
37 segment.
38
39 Note that the code in the .init section has already been run.
40 This includes _init and _libc_init
41
42 The stack pointer, sp, will point to the argument count on the stack.
43 The initial state of the stack when a userspace process is started is:
44
45 Purpose Start Address Length
46 Unspecified High Addresses
47 Referenced strings, etc. Varies
48 Unspecified
49 Null auxilliary vector entry 4bytes
50 Auxilliary vector entries 8bytes each
51 NULL terminator for envp 4bytes
52 Environment pointers sp+8+4*argc 4bytes each
53 NULL terminator for argv sp+4+4*argc 4bytes
54 Argument pointers sp+4 4bytes each
55 Argument count sp 4bytes
56 Unspecified Low Addresses
57
58 If the application should register a destructor function with atexit,
59 the pointer will be placed in r4. Otherwise r4 will be zero.
60
61 The contents of all other registers are unspecified. User code should
62 set fp to zero to mark the end of the frame chain.
63
64 The auxilliary vector is a series of pairs of 32-bit tag and 32-bit
65 value, terminated by an AT_NULL tag.
66*/
67
68 .text
69 .globl _start
70 .type _start,%function
71_start:
72 /* Set up the global pointer. */
73 movhi gp, %hiadj(_gp)
74 addi gp, gp, %lo(_gp)
75
76 /* Save the stack pointer. */
77 mov r2, sp
78
79 /* Create room on the stack for the fini, rtld_fini and stack_end args
80 to __libc_start_main. */
81 subi sp, sp, 12
82
83 /* Push stack_end */
84 stw r2, 8(sp)
85
86 /* Push rtld_fini */
87 stw r4, 4(sp)
88
89 /* Set up the GOT pointer. */
90 nextpc r22
911: movhi r2, %hiadj(_gp_got - 1b)
92 addi r2, r2, %lo(_gp_got - 1b)
93 add r22, r22, r2
94
95 /* Push fini */
96 movhi r8, %call_hiadj(__libc_csu_fini)
97 addi r8, r8, %call_lo(__libc_csu_fini)
98 add r8, r8, r22
99 ldw r8, 0(r8)
100 stw r8, 0(sp)
101
102 /* r7 == init */
103 movhi r7, %call_hiadj(__libc_csu_init)
104 addi r7, r7, %call_lo(__libc_csu_init)
105 add r7, r7, r22
106 ldw r7, 0(r7)
107
108 /* r6 == argv */
109 addi r6, sp, 16
110
111 /* r5 == argc */
112 ldw r5, 12(sp)
113
114 /* r4 == main */
115 movhi r4, %call_hiadj(main)
116 addi r4, r4, %call_lo(main)
117 add r4, r4, r22
118 ldw r4, 0(r4)
119
120 /* fp == 0 */
121 mov fp, zero
122
123 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
124 stack_end) */
125
126 /* Let the libc call main and exit with its return code. */
127 movhi r2, %call_hiadj(__libc_start_main)
128 addi r2, r2, %call_lo(__libc_start_main)
129 add r2, r2, r22
130 ldw r2, 0(r2)
131 callr r2
132
133 /* should never get here....*/
134 movhi r2, %call_hiadj(abort)
135 addi r2, r2, %call_lo(abort)
136 add r2, r2, r22
137 ldw r2, 0(r2)
138 callr r2
139
140/* Define a symbol for the first piece of initialized data. */
141 .data
142 .globl __data_start
143__data_start:
144 .long 0
145 .weak data_start
146 data_start = __data_start
libc/glibc/sysdeps/nios2/sysdep.h created+65
...@@ -0,0 +1,65 @@
1/* Assembler macros for Nios II.
2 Copyright (C) 2015-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Syntactic details of assembler. */
24
25#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
26
27#define ENTRY(name) \
28 .globl C_SYMBOL_NAME(name); \
29 .type C_SYMBOL_NAME(name),%function; \
30 C_LABEL(name) \
31 cfi_startproc; \
32 CALL_MCOUNT;
33
34#undef END
35#define END(name) \
36 cfi_endproc; \
37 ASM_SIZE_DIRECTIVE(name)
38
39#ifdef PROF
40
41# ifdef __PIC__
42# define CALL_MCOUNT \
43 mov r8, ra; \
44 nextpc r2; \
451: \
46 movhi r3, %hiadj(_gp_got - 1b); \
47 addi r3, r3, %lo(_gp_got - 1b); \
48 add r2, r2, r3; \
49 ldw r2, %call(_mcount)(r2); \
50 callr r2; \
51 mov ra, r8; \
52 ret;
53# else
54# define CALL_MCOUNT \
55 mov r8, ra; \
56 call _mount; \
57 mov ra, r8; \
58 ret;
59# endif
60
61#else
62# define CALL_MCOUNT /* Do nothing. */
63#endif
64
65#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/nptl/lowlevellock.h deleted-204
...@@ -1,204 +0,0 @@
1/* Low-level lock implementation. Generic futex-based version.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LOWLEVELLOCK_H
20#define _LOWLEVELLOCK_H 1
21
22#include <atomic.h>
23#include <lowlevellock-futex.h>
24
25/* Low-level locks use a combination of atomic operations (to acquire and
26 release lock ownership) and futex operations (to block until the state
27 of a lock changes). A lock can be in one of three states:
28 0: not acquired,
29 1: acquired with no waiters; no other threads are blocked or about to block
30 for changes to the lock state,
31 >1: acquired, possibly with waiters; there may be other threads blocked or
32 about to block for changes to the lock state.
33
34 We expect that the common case is an uncontended lock, so we just need
35 to transition the lock between states 0 and 1; releasing the lock does
36 not need to wake any other blocked threads. If the lock is contended
37 and a thread decides to block using a futex operation, then this thread
38 needs to first change the state to >1; if this state is observed during
39 lock release, the releasing thread will wake one of the potentially
40 blocked threads.
41
42 Much of this code takes a 'private' parameter. This may be:
43 LLL_PRIVATE: lock only shared within a process
44 LLL_SHARED: lock may be shared across processes.
45
46 Condition variables contain an optimization for broadcasts that requeues
47 waiting threads on a lock's futex. Therefore, there is a special
48 variant of the locks (whose name contains "cond") that makes sure to
49 always set the lock state to >1 and not just 1.
50
51 Robust locks set the lock to the id of the owner. This allows detection
52 of the case where the owner exits without releasing the lock. Flags are
53 OR'd with the owner id to record additional information about lock state.
54 Therefore the states of robust locks are:
55 0: not acquired
56 id: acquired (by user identified by id & FUTEX_TID_MASK)
57
58 The following flags may be set in the robust lock value:
59 FUTEX_WAITERS - possibly has waiters
60 FUTEX_OWNER_DIED - owning user has exited without releasing the futex. */
61
62
63/* If LOCK is 0 (not acquired), set to 1 (acquired with no waiters) and return
64 0. Otherwise leave lock unchanged and return non-zero to indicate that the
65 lock was not acquired. */
66#define lll_trylock(lock) \
67 __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 1, 0))
68
69/* If LOCK is 0 (not acquired), set to 2 (acquired, possibly with waiters) and
70 return 0. Otherwise leave lock unchanged and return non-zero to indicate
71 that the lock was not acquired. */
72#define lll_cond_trylock(lock) \
73 __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 2, 0))
74
75extern void __lll_lock_wait_private (int *futex) attribute_hidden;
76extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
77
78/* This is an expression rather than a statement even though its value is
79 void, so that it can be used in a comma expression or as an expression
80 that's cast to void. */
81/* The inner conditional compiles to a call to __lll_lock_wait_private if
82 private is known at compile time to be LLL_PRIVATE, and to a call to
83 __lll_lock_wait otherwise. */
84/* If FUTEX is 0 (not acquired), set to 1 (acquired with no waiters) and
85 return. Otherwise, ensure that it is >1 (acquired, possibly with waiters)
86 and then block until we acquire the lock, at which point FUTEX will still be
87 >1. The lock is always acquired on return. */
88#define __lll_lock(futex, private) \
89 ((void) \
90 ({ \
91 int *__futex = (futex); \
92 if (__glibc_unlikely \
93 (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
94 { \
95 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
96 __lll_lock_wait_private (__futex); \
97 else \
98 __lll_lock_wait (__futex, private); \
99 } \
100 }))
101#define lll_lock(futex, private) \
102 __lll_lock (&(futex), private)
103
104
105/* This is an expression rather than a statement even though its value is
106 void, so that it can be used in a comma expression or as an expression
107 that's cast to void. */
108/* Unconditionally set FUTEX to 2 (acquired, possibly with waiters). If FUTEX
109 was 0 (not acquired) then return. Otherwise, block until the lock is
110 acquired, at which point FUTEX is 2 (acquired, possibly with waiters). The
111 lock is always acquired on return. */
112#define __lll_cond_lock(futex, private) \
113 ((void) \
114 ({ \
115 int *__futex = (futex); \
116 if (__glibc_unlikely (atomic_exchange_acq (__futex, 2) != 0)) \
117 __lll_lock_wait (__futex, private); \
118 }))
119#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
120
121
122extern int __lll_timedlock_wait (int *futex, const struct timespec *,
123 int private) attribute_hidden;
124
125
126/* As __lll_lock, but with a timeout. If the timeout occurs then return
127 ETIMEDOUT. If ABSTIME is invalid, return EINVAL. */
128#define __lll_timedlock(futex, abstime, private) \
129 ({ \
130 int *__futex = (futex); \
131 int __val = 0; \
132 \
133 if (__glibc_unlikely \
134 (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
135 __val = __lll_timedlock_wait (__futex, abstime, private); \
136 __val; \
137 })
138#define lll_timedlock(futex, abstime, private) \
139 __lll_timedlock (&(futex), abstime, private)
140
141
142/* This is an expression rather than a statement even though its value is
143 void, so that it can be used in a comma expression or as an expression
144 that's cast to void. */
145/* Unconditionally set FUTEX to 0 (not acquired), releasing the lock. If FUTEX
146 was >1 (acquired, possibly with waiters), then wake any waiters. The waiter
147 that acquires the lock will set FUTEX to >1.
148 Evaluate PRIVATE before releasing the lock so that we do not violate the
149 mutex destruction requirements. Specifically, we need to ensure that
150 another thread can destroy the mutex (and reuse its memory) once it
151 acquires the lock and when there will be no further lock acquisitions;
152 thus, we must not access the lock after releasing it, or those accesses
153 could be concurrent with mutex destruction or reuse of the memory. */
154#define __lll_unlock(futex, private) \
155 ((void) \
156 ({ \
157 int *__futex = (futex); \
158 int __private = (private); \
159 int __oldval = atomic_exchange_rel (__futex, 0); \
160 if (__glibc_unlikely (__oldval > 1)) \
161 lll_futex_wake (__futex, 1, __private); \
162 }))
163#define lll_unlock(futex, private) \
164 __lll_unlock (&(futex), private)
165
166
167#define lll_islocked(futex) \
168 ((futex) != LLL_LOCK_INITIALIZER)
169
170
171/* Our internal lock implementation is identical to the binary-compatible
172 mutex implementation. */
173
174/* Initializers for lock. */
175#define LLL_LOCK_INITIALIZER (0)
176#define LLL_LOCK_INITIALIZER_LOCKED (1)
177
178extern int __lll_timedwait_tid (int *, const struct timespec *)
179 attribute_hidden;
180
181/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
182 wake-up when the clone terminates. The memory location contains the
183 thread ID while the clone is running and is reset to zero by the kernel
184 afterwards. The kernel up to version 3.16.3 does not use the private futex
185 operations for futex wake-up when the clone terminates.
186 If ABSTIME is not NULL, is used a timeout for futex call. If the timeout
187 occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL.
188 The futex operation are issues with cancellable versions. */
189#define lll_wait_tid(tid, abstime) \
190 ({ \
191 int __res = 0; \
192 __typeof (tid) __tid; \
193 if (abstime != NULL) \
194 __res = __lll_timedwait_tid (&(tid), (abstime)); \
195 else \
196 /* We need acquire MO here so that we synchronize with the \
197 kernel's store to 0 when the clone terminates. (see above) */ \
198 while ((__tid = atomic_load_acquire (&(tid))) != 0) \
199 lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \
200 __res; \
201 })
202
203
204#endif /* lowlevellock.h */
libc/glibc/sysdeps/powerpc/bits/endian.h created+36
...@@ -0,0 +1,36 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* PowerPC can be little or big endian. Hopefully gcc will know... */
19
20#ifndef _ENDIAN_H
21# error "Never use <bits/endian.h> directly; include <endian.h> instead."
22#endif
23
24#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN
25# if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN
26# error Both BIG_ENDIAN and LITTLE_ENDIAN defined!
27# endif
28# define __BYTE_ORDER __BIG_ENDIAN
29#else
30# if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN
31# define __BYTE_ORDER __LITTLE_ENDIAN
32# else
33# warning Cannot determine current byte order, assuming big-endian.
34# define __BYTE_ORDER __BIG_ENDIAN
35# endif
36#endif
libc/glibc/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h created+81
...@@ -0,0 +1,81 @@
1/* Machine-specific pthread type layouts. PowerPC version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <bits/wordsize.h>
23
24#if __WORDSIZE == 64
25# define __SIZEOF_PTHREAD_MUTEX_T 40
26# define __SIZEOF_PTHREAD_ATTR_T 56
27# define __SIZEOF_PTHREAD_RWLOCK_T 56
28# define __SIZEOF_PTHREAD_BARRIER_T 32
29#else
30# define __SIZEOF_PTHREAD_MUTEX_T 24
31# define __SIZEOF_PTHREAD_ATTR_T 36
32# define __SIZEOF_PTHREAD_RWLOCK_T 32
33# define __SIZEOF_PTHREAD_BARRIER_T 20
34#endif
35#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
36#define __SIZEOF_PTHREAD_COND_T 48
37#define __SIZEOF_PTHREAD_CONDATTR_T 4
38#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
39#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
40
41/* Definitions for internal mutex struct. */
42#define __PTHREAD_COMPAT_PADDING_MID
43#define __PTHREAD_COMPAT_PADDING_END
44#define __PTHREAD_MUTEX_LOCK_ELISION 1
45#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64)
46#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64)
47
48#define __LOCK_ALIGNMENT
49#define __ONCE_ALIGNMENT
50
51struct __pthread_rwlock_arch_t
52{
53 unsigned int __readers;
54 unsigned int __writers;
55 unsigned int __wrphase_futex;
56 unsigned int __writers_futex;
57 unsigned int __pad3;
58 unsigned int __pad4;
59#if __WORDSIZE == 64
60 int __cur_writer;
61 int __shared;
62 unsigned char __rwelision;
63 unsigned char __pad1[7];
64 unsigned long int __pad2;
65 /* FLAGS must stay at this position in the structure to maintain
66 binary compatibility. */
67 unsigned int __flags;
68# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, {0, 0, 0, 0, 0, 0, 0 }
69#else
70 unsigned char __rwelision;
71 unsigned char __pad2;
72 unsigned char __shared;
73 /* FLAGS must stay at this position in the structure to maintain
74 binary compatibility. */
75 unsigned char __flags;
76 int __cur_writer;
77# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
78#endif
79};
80
81#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/powerpc/powerpc32/crti.S created+91
...@@ -0,0 +1,91 @@
1/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 stwu r1, -16(r1)
65 mflr r0
66 stw r0, 20(r1)
67 stw r30, 8(r1)
68 SETUP_GOT_ACCESS (r30, .Lgot_label_i)
69 addis r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@ha
70 addi r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@l
71#if PREINIT_FUNCTION_WEAK
72 lwz r0, PREINIT_FUNCTION@got(r30)
73 cmpwi cr7, r0, 0
74 beq+ cr7, 1f
75 bl PREINIT_FUNCTION@plt
761:
77#else
78 bl PREINIT_FUNCTION@local
79#endif
80
81 .section .fini,"ax",@progbits
82 .align 2
83 .globl _fini
84 .hidden _fini
85 .type _fini, @function
86_fini:
87 stwu r1, -16(r1)
88 mflr r0
89 stw r0, 20(r1)
90 stw r30, 8(r1)
91 SETUP_GOT_ACCESS (r30, .Lgot_label_f)
libc/glibc/sysdeps/powerpc/powerpc32/crtn.S created+53
...@@ -0,0 +1,53 @@
1/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 lwz r0, 20(r1)
43 mtlr r0
44 lwz r30, 8(r1)
45 addi r1, r1, 16
46 blr
47
48 .section .fini,"ax",@progbits
49 lwz r0, 20(r1)
50 mtlr r0
51 lwz r30, 8(r1)
52 addi r1, r1, 16
53 blr
libc/glibc/sysdeps/powerpc/powerpc32/dl-dtprocnum.h created+3
...@@ -0,0 +1,3 @@
1/* Number of extra dynamic section entries for this architecture. By
2 default there are none. */
3#define DT_THISPROCNUM DT_PPC_NUM
libc/glibc/sysdeps/powerpc/powerpc32/start.S created+95
...@@ -0,0 +1,95 @@
1/* Startup code for programs linked with GNU libc.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38/* We do not want .eh_frame info for crt1.o since crt1.o is linked
39 before crtbegin.o, the file defining __EH_FRAME_BEGIN__. */
40#undef cfi_startproc
41#define cfi_startproc
42#undef cfi_endproc
43#define cfi_endproc
44
45 /* These are the various addresses we require. */
46#ifdef PIC
47 .section ".data"
48#else
49 .section ".rodata"
50#endif
51 .align 2
52L(start_addresses):
53 .long _SDA_BASE_
54 .long main
55 .long __libc_csu_init
56 .long __libc_csu_fini
57 ASM_SIZE_DIRECTIVE(L(start_addresses))
58
59 .section ".text"
60ENTRY(_start)
61 /* Save the stack pointer, in case we're statically linked under Linux. */
62 mr r9,r1
63 /* Set up an initial stack frame, and clear the LR. */
64 clrrwi r1,r1,4
65#ifdef PIC
66 SETUP_GOT_ACCESS(r13,got_label)
67 li r0,0
68#else
69 li r0,0
70#endif
71 stwu r1,-16(r1)
72 mtlr r0
73 stw r0,0(r1)
74 /* Set r13 to point at the 'small data area', and put the address of
75 start_addresses in r8. Also load the GOT pointer so that new PLT
76 calls work, like the one to __libc_start_main. */
77#ifdef PIC
78 addis r30,r13,_GLOBAL_OFFSET_TABLE_-got_label@ha
79 addis r8,r13,L(start_addresses)-got_label@ha
80 addi r30,r30,_GLOBAL_OFFSET_TABLE_-got_label@l
81 lwzu r13, L(start_addresses)-got_label@l(r8)
82#else
83 lis r8,L(start_addresses)@ha
84 lwzu r13,L(start_addresses)@l(r8)
85#endif
86 /* and continue in libc-start, in glibc. */
87 b JUMPTARGET(__libc_start_main)
88END(_start)
89
90/* Define a symbol for the first piece of initialized data. */
91 .section ".data"
92 .globl __data_start
93__data_start:
94 .long 0
95weak_alias (__data_start, data_start)
libc/glibc/sysdeps/powerpc/powerpc32/symbol-hacks.h created+21
...@@ -0,0 +1,21 @@
1/* Hacks needed for symbol manipulation. powerpc version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
20
21#include_next "symbol-hacks.h"
libc/glibc/sysdeps/powerpc/powerpc32/sysdep.h created+160
...@@ -0,0 +1,160 @@
1/* Assembly macros for 32-bit PowerPC.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/powerpc/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* If compiled for profiling, call `_mcount' at the start of each
24 function. */
25#ifdef PROF
26/* The mcount code relies on a the return address being on the stack
27 to locate our caller and so it can restore it; so store one just
28 for its benefit. */
29# define CALL_MCOUNT \
30 mflr r0; \
31 stw r0,4(r1); \
32 cfi_offset (lr, 4); \
33 bl JUMPTARGET(_mcount);
34#else /* PROF */
35# define CALL_MCOUNT /* Do nothing. */
36#endif /* PROF */
37
38#define ENTRY(name) \
39 .globl C_SYMBOL_NAME(name); \
40 .type C_SYMBOL_NAME(name),@function; \
41 .align ALIGNARG(2); \
42 C_LABEL(name) \
43 cfi_startproc; \
44 CALL_MCOUNT
45
46#define ENTRY_TOCLESS(name) ENTRY(name)
47
48/* helper macro for accessing the 32-bit powerpc GOT. */
49
50#define SETUP_GOT_ACCESS(regname,GOT_LABEL) \
51 bcl 20,31,GOT_LABEL ; \
52GOT_LABEL: ; \
53 mflr (regname)
54
55#define EALIGN_W_0 /* No words to insert. */
56#define EALIGN_W_1 nop
57#define EALIGN_W_2 nop;nop
58#define EALIGN_W_3 nop;nop;nop
59#define EALIGN_W_4 EALIGN_W_3;nop
60#define EALIGN_W_5 EALIGN_W_4;nop
61#define EALIGN_W_6 EALIGN_W_5;nop
62#define EALIGN_W_7 EALIGN_W_6;nop
63
64/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
65 past a 2^align boundary. */
66#ifdef PROF
67# define EALIGN(name, alignt, words) \
68 .globl C_SYMBOL_NAME(name); \
69 .type C_SYMBOL_NAME(name),@function; \
70 .align ALIGNARG(2); \
71 C_LABEL(name) \
72 cfi_startproc; \
73 CALL_MCOUNT \
74 b 0f; \
75 .align ALIGNARG(alignt); \
76 EALIGN_W_##words; \
77 0:
78#else /* PROF */
79# define EALIGN(name, alignt, words) \
80 .globl C_SYMBOL_NAME(name); \
81 .type C_SYMBOL_NAME(name),@function; \
82 .align ALIGNARG(alignt); \
83 EALIGN_W_##words; \
84 C_LABEL(name) \
85 cfi_startproc;
86#endif
87
88#undef END
89#define END(name) \
90 cfi_endproc; \
91 ASM_SIZE_DIRECTIVE(name)
92
93#define DO_CALL(syscall) \
94 li 0,syscall; \
95 sc
96
97#undef JUMPTARGET
98#ifdef PIC
99# define JUMPTARGET(name) name##@plt
100#else
101# define JUMPTARGET(name) name
102#endif
103
104#if defined SHARED && defined PIC && !defined NO_HIDDEN
105# undef HIDDEN_JUMPTARGET
106# define HIDDEN_JUMPTARGET(name) __GI_##name##@local
107#endif
108
109#define PSEUDO(name, syscall_name, args) \
110 .section ".text"; \
111 ENTRY (name) \
112 DO_CALL (SYS_ify (syscall_name));
113
114#define PSEUDO_RET \
115 bnslr+; \
116 b __syscall_error@local
117#define ret PSEUDO_RET
118
119#undef PSEUDO_END
120#define PSEUDO_END(name) \
121 END (name)
122
123#define PSEUDO_NOERRNO(name, syscall_name, args) \
124 .section ".text"; \
125 ENTRY (name) \
126 DO_CALL (SYS_ify (syscall_name));
127
128#define PSEUDO_RET_NOERRNO \
129 blr
130#define ret_NOERRNO PSEUDO_RET_NOERRNO
131
132#undef PSEUDO_END_NOERRNO
133#define PSEUDO_END_NOERRNO(name) \
134 END (name)
135
136#define PSEUDO_ERRVAL(name, syscall_name, args) \
137 .section ".text"; \
138 ENTRY (name) \
139 DO_CALL (SYS_ify (syscall_name));
140
141#define PSEUDO_RET_ERRVAL \
142 blr
143#define ret_ERRVAL PSEUDO_RET_ERRVAL
144
145#undef PSEUDO_END_ERRVAL
146#define PSEUDO_END_ERRVAL(name) \
147 END (name)
148
149/* Local labels stripped out by the linker. */
150#undef L
151#define L(x) .L##x
152
153#define XGLUE(a,b) a##b
154#define GLUE(a,b) XGLUE (a,b)
155#define GENERATE_GOT_LABEL(name) GLUE (.got_label, name)
156
157/* Label in text section. */
158#define C_TEXT(name) name
159
160#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/powerpc/powerpc64/crti.S created+90
...@@ -0,0 +1,90 @@
1/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58#if PREINIT_FUNCTION_WEAK
59 .section ".toc", "aw"
60.LC0:
61 .tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION
62#endif
63 .section ".init", "ax", @progbits
64 ENTRY_2(_init)
65 .hidden _init
66 .align ALIGNARG (2)
67BODY_LABEL (_init):
68 LOCALENTRY(_init)
69 mflr 0
70 std 0, FRAME_LR_SAVE(r1)
71 stdu r1, -FRAME_MIN_SIZE_PARM(r1)
72#if PREINIT_FUNCTION_WEAK
73 addis r9, r2, .LC0@toc@ha
74 ld r0, .LC0@toc@l(r9)
75 cmpdi cr7, r0, 0
76 beq+ cr7, 1f
77#endif
78 bl JUMPTARGET (PREINIT_FUNCTION)
79 nop
801:
81
82 .section ".fini", "ax", @progbits
83 ENTRY_2(_fini)
84 .hidden _fini
85 .align ALIGNARG (2)
86BODY_LABEL (_fini):
87 LOCALENTRY(_fini)
88 mflr 0
89 std 0, FRAME_LR_SAVE(r1)
90 stdu r1, -FRAME_MIN_SIZE_PARM(r1)
libc/glibc/sysdeps/powerpc/powerpc64/crtn.S created+51
...@@ -0,0 +1,51 @@
1/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 addi r1, r1, FRAME_MIN_SIZE_PARM
43 ld r0, FRAME_LR_SAVE(r1)
44 mtlr r0
45 blr
46
47 .section .fini,"ax",@progbits
48 addi r1, r1, FRAME_MIN_SIZE_PARM
49 ld r0, FRAME_LR_SAVE(r1)
50 mtlr r0
51 blr
libc/glibc/sysdeps/powerpc/powerpc64/dl-dtprocnum.h created+21
...@@ -0,0 +1,21 @@
1/* Configuration of lookup functions. PowerPC64 version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Number of extra dynamic section entries for this architecture. By
20 default there are none. */
21#define DT_THISPROCNUM DT_PPC64_NUM
libc/glibc/sysdeps/powerpc/powerpc64/start.S created+92
...@@ -0,0 +1,92 @@
1/* Startup code for programs linked with GNU libc. PowerPC64 version.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38/* We do not want .eh_frame info for crt1.o since crt1.o is linked
39 before crtbegin.o, the file defining __EH_FRAME_BEGIN__. */
40#undef cfi_startproc
41#define cfi_startproc
42#undef cfi_endproc
43#define cfi_endproc
44
45 /* These are the various addresses we require. */
46#ifdef PIC
47 .section ".data.rel.ro.local","aw"
48#else
49 .section ".rodata"
50#endif
51 .align 3
52L(start_addresses):
53 .quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
54/* function descriptors so don't need JUMPTARGET */
55 .quad main
56 .quad __libc_csu_init
57 .quad __libc_csu_fini
58
59 ASM_SIZE_DIRECTIVE(L(start_addresses))
60
61 .section ".toc","aw"
62.L01:
63 .tc L(start_addresses)[TC],L(start_addresses)
64 .section ".text"
65ENTRY (_start)
66 /* Save the stack pointer, in case we're statically linked under Linux. */
67 mr r9,r1
68 /* Set up an initial stack frame, and clear the LR. */
69 clrrdi r1,r1,4
70 li r0,0
71 stdu r1,-128(r1)
72 mtlr r0
73 std r0,0(r1)
74
75 /* put the address of start_addresses in r8... **
76** PPC64 ABI uses R13 for thread local, so we leave it alone */
77 ld r8,.L01@toc(r2)
78
79 /* and continue in libc-start, in glibc. */
80 b JUMPTARGET(__libc_start_main)
81/* Older versions of ld need this nop to recognize that it's OK to call via a
82 TOC adjusting stub. */
83 nop
84
85END(_start)
86
87/* Define a symbol for the first piece of initialized data. */
88 .section ".data"
89 .globl __data_start
90__data_start:
91 .long 0
92weak_alias (__data_start, data_start)
libc/glibc/sysdeps/powerpc/powerpc64/sysdep.h created+400
...@@ -0,0 +1,400 @@
1/* Assembly macros for 64-bit PowerPC.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/powerpc/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Stack frame offsets. */
24#define FRAME_BACKCHAIN 0
25#define FRAME_CR_SAVE 8
26#define FRAME_LR_SAVE 16
27#if _CALL_ELF != 2
28#define FRAME_MIN_SIZE 112
29#define FRAME_MIN_SIZE_PARM 112
30#define FRAME_TOC_SAVE 40
31#define FRAME_PARM_SAVE 48
32#else
33#define FRAME_MIN_SIZE 32
34#define FRAME_MIN_SIZE_PARM 96
35#define FRAME_TOC_SAVE 24
36#define FRAME_PARM_SAVE 32
37#endif
38
39/* Support macros for CALL_MCOUNT. */
40 .macro SAVE_ARG NARG
41 .if \NARG
42 SAVE_ARG \NARG-1
43 std 2+\NARG,-FRAME_MIN_SIZE_PARM+FRAME_PARM_SAVE-8+8*(\NARG)(1)
44 .endif
45 .endm
46
47 .macro REST_ARG NARG
48 .if \NARG
49 REST_ARG \NARG-1
50 ld 2+\NARG,FRAME_PARM_SAVE-8+8*(\NARG)(1)
51 .endif
52 .endm
53
54 .macro CFI_SAVE_ARG NARG
55 .if \NARG
56 CFI_SAVE_ARG \NARG-1
57 cfi_offset(2+\NARG,-FRAME_MIN_SIZE_PARM+FRAME_PARM_SAVE-8+8*(\NARG))
58 .endif
59 .endm
60
61 .macro CFI_REST_ARG NARG
62 .if \NARG
63 CFI_REST_ARG \NARG-1
64 cfi_restore(2+\NARG)
65 .endif
66 .endm
67
68/* If compiled for profiling, call `_mcount' at the start of each function.
69 see ppc-mcount.S for more details. */
70 .macro CALL_MCOUNT NARG
71#ifdef PROF
72 mflr r0
73 SAVE_ARG \NARG
74 std r0,FRAME_LR_SAVE(r1)
75 stdu r1,-FRAME_MIN_SIZE_PARM(r1)
76 cfi_adjust_cfa_offset(FRAME_MIN_SIZE_PARM)
77 cfi_offset(lr,FRAME_LR_SAVE)
78 CFI_SAVE_ARG \NARG
79 bl JUMPTARGET (_mcount)
80#ifndef SHARED
81 nop
82#endif
83 ld r0,FRAME_MIN_SIZE_PARM+FRAME_LR_SAVE(r1)
84 REST_ARG \NARG
85 mtlr r0
86 addi r1,r1,FRAME_MIN_SIZE_PARM
87 cfi_adjust_cfa_offset(-FRAME_MIN_SIZE_PARM)
88 cfi_restore(lr)
89 CFI_REST_ARG \NARG
90#endif
91 .endm
92
93#if _CALL_ELF != 2
94
95/* Macro to prepare for calling via a function pointer. */
96 .macro PPC64_LOAD_FUNCPTR PTR
97 ld r12,0(\PTR)
98 ld r2,8(\PTR)
99 mtctr r12
100 ld r11,16(\PTR)
101 .endm
102
103#ifdef USE_PPC64_OVERLAPPING_OPD
104# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase
105#else
106# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase, 0
107#endif
108
109#define ENTRY_1(name) \
110 .type BODY_LABEL(name),@function; \
111 .globl name; \
112 .section ".opd","aw"; \
113 .p2align 3;FUNC_LABEL(name): \
114 OPD_ENT (name); \
115 .previous
116
117#define FUNC_LABEL(X) X
118#define BODY_LABEL(X) .LY##X
119#define ENTRY_2(name) \
120 .type name,@function; \
121 ENTRY_1(name)
122#define END_2(name) \
123 .size name,.-BODY_LABEL(name); \
124 .size BODY_LABEL(name),.-BODY_LABEL(name)
125#define LOCALENTRY(name)
126
127#else /* _CALL_ELF == 2 */
128
129/* Macro to prepare for calling via a function pointer. */
130 .macro PPC64_LOAD_FUNCPTR PTR
131 mr r12,\PTR
132 mtctr r12
133 .endm
134
135#define FUNC_LABEL(X) X
136#define BODY_LABEL(X) X
137#define ENTRY_2(name) \
138 .globl name; \
139 .type name,@function
140#define END_2(name) \
141 .size name,.-name
142#define LOCALENTRY(name) \
1431: addis r2,r12,.TOC.-1b@ha; \
144 addi r2,r2,.TOC.-1b@l; \
145 .localentry name,.-name
146
147#endif /* _CALL_ELF */
148
149 .macro NOPS NARG
150 .if \NARG
151 NOPS \NARG-1
152 nop
153 .endif
154 .endm
155
156 .macro ENTRY_3 name, alignp2=2, nopwords=0
157 .text
158 ENTRY_2(\name)
159 .p2align \alignp2
160 NOPS \nopwords
161BODY_LABEL(\name):
162 .endm
163
164/* Use ENTRY_TOCLESS for functions that make no use of r2 and
165 guarantee r2 is unchanged on exit. Any function that has @toc or
166 @got relocs uses r2. Functions that call other functions via the
167 PLT use r2. Use ENTRY for functions that may use or change r2.
168 The first argument is the function name.
169 The optional second argument specifies alignment of the function's
170 code, as the logarithm base two of the byte alignment. For
171 example, a value of four aligns to a sixteen byte boundary.
172 The optional third argument specifies the number of NOPs to emit
173 before the start of the function's code. */
174#ifndef PROF
175#define ENTRY_TOCLESS(name, ...) \
176 ENTRY_3 name, ## __VA_ARGS__; \
177 cfi_startproc
178
179#define ENTRY(name, ...) \
180 ENTRY_TOCLESS(name, ## __VA_ARGS__); \
181 LOCALENTRY(name)
182#else
183/* The call to _mcount is potentially via the plt, so profiling code
184 is never free of an r2 use. */
185#define ENTRY_TOCLESS(name, ...) \
186 ENTRY_3 name, ## __VA_ARGS__; \
187 cfi_startproc; \
188 LOCALENTRY(name)
189
190#define ENTRY(name, ...) \
191 ENTRY_TOCLESS(name, ## __VA_ARGS__)
192#endif
193
194/* Local labels stripped out by the linker. */
195#undef L
196#define L(x) .L##x
197
198#define tostring(s) #s
199#define stringify(s) tostring(s)
200#define XGLUE(a,b) a##b
201#define GLUE(a,b) XGLUE(a,b)
202#define LT_LABEL(name) GLUE(.LT,name)
203#define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix)
204
205/* Support Traceback tables */
206#define TB_ASM 0x000c000000000000
207#define TB_GLOBALLINK 0x0000800000000000
208#define TB_IS_EPROL 0x0000400000000000
209#define TB_HAS_TBOFF 0x0000200000000000
210#define TB_INT_PROC 0x0000100000000000
211#define TB_HAS_CTL 0x0000080000000000
212#define TB_TOCLESS 0x0000040000000000
213#define TB_FP_PRESENT 0x0000020000000000
214#define TB_LOG_ABORT 0x0000010000000000
215#define TB_INT_HANDL 0x0000008000000000
216#define TB_NAME_PRESENT 0x0000004000000000
217#define TB_USES_ALLOCA 0x0000002000000000
218#define TB_SAVES_CR 0x0000000200000000
219#define TB_SAVES_LR 0x0000000100000000
220#define TB_STORES_BC 0x0000000080000000
221#define TB_FIXUP 0x0000000040000000
222#define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24)
223#define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16)
224#define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8)
225#define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1)
226#define TB_PARMSONSTK 0x0000000000000001
227
228#define PPC_HIGHER(v) (((v) >> 32) & 0xffff)
229#define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT
230
231#define TRACEBACK(name) \
232LT_LABEL(name): ; \
233 .long 0 ; \
234 .quad TB_DEFAULT ; \
235 .long LT_LABEL(name)-BODY_LABEL(name) ; \
236 .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
237LT_LABELSUFFIX(name,_name_start): ;\
238 .ascii stringify(name) ; \
239LT_LABELSUFFIX(name,_name_end): ; \
240 .p2align 2
241
242#define TRACEBACK_MASK(name,mask) \
243LT_LABEL(name): ; \
244 .long 0 ; \
245 .quad TB_DEFAULT | mask ; \
246 .long LT_LABEL(name)-BODY_LABEL(name) ; \
247 .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
248LT_LABELSUFFIX(name,_name_start): ;\
249 .ascii stringify(name) ; \
250LT_LABELSUFFIX(name,_name_end): ; \
251 .p2align 2
252
253/* END generates Traceback tables */
254#undef END
255#define END(name) \
256 cfi_endproc; \
257 TRACEBACK(name); \
258 END_2(name)
259
260/* This form supports more informative traceback tables */
261#define END_GEN_TB(name,mask) \
262 cfi_endproc; \
263 TRACEBACK_MASK(name,mask); \
264 END_2(name)
265
266#define DO_CALL(syscall) \
267 li 0,syscall; \
268 sc
269
270/* ppc64 is always PIC */
271#undef JUMPTARGET
272#define JUMPTARGET(name) FUNC_LABEL(name)
273
274#define PSEUDO(name, syscall_name, args) \
275 .section ".text"; \
276 ENTRY (name); \
277 DO_CALL (SYS_ify (syscall_name))
278
279#ifdef SHARED
280#define TAIL_CALL_SYSCALL_ERROR \
281 b JUMPTARGET(__syscall_error)
282#else
283/* Static version might be linked into a large app with a toc exceeding
284 64k. We can't put a toc adjusting stub on a plain branch, so can't
285 tail call __syscall_error. */
286#define TAIL_CALL_SYSCALL_ERROR \
287 .ifdef .Local_syscall_error; \
288 b .Local_syscall_error; \
289 .else; \
290.Local_syscall_error: \
291 mflr 0; \
292 std 0,FRAME_LR_SAVE(1); \
293 stdu 1,-FRAME_MIN_SIZE(1); \
294 cfi_adjust_cfa_offset(FRAME_MIN_SIZE); \
295 cfi_offset(lr,FRAME_LR_SAVE); \
296 bl JUMPTARGET(__syscall_error); \
297 nop; \
298 ld 0,FRAME_MIN_SIZE+FRAME_LR_SAVE(1); \
299 addi 1,1,FRAME_MIN_SIZE; \
300 cfi_adjust_cfa_offset(-FRAME_MIN_SIZE); \
301 mtlr 0; \
302 cfi_restore(lr); \
303 blr; \
304 .endif
305#endif
306
307#define PSEUDO_RET \
308 bnslr+; \
309 TAIL_CALL_SYSCALL_ERROR
310
311#define ret PSEUDO_RET
312
313#undef PSEUDO_END
314#define PSEUDO_END(name) \
315 END (name)
316
317#define PSEUDO_NOERRNO(name, syscall_name, args) \
318 .section ".text"; \
319 ENTRY (name); \
320 DO_CALL (SYS_ify (syscall_name))
321
322#define PSEUDO_RET_NOERRNO \
323 blr
324
325#define ret_NOERRNO PSEUDO_RET_NOERRNO
326
327#undef PSEUDO_END_NOERRNO
328#define PSEUDO_END_NOERRNO(name) \
329 END (name)
330
331#define PSEUDO_ERRVAL(name, syscall_name, args) \
332 .section ".text"; \
333 ENTRY (name); \
334 DO_CALL (SYS_ify (syscall_name))
335
336#define PSEUDO_RET_ERRVAL \
337 blr
338
339#define ret_ERRVAL PSEUDO_RET_ERRVAL
340
341#undef PSEUDO_END_ERRVAL
342#define PSEUDO_END_ERRVAL(name) \
343 END (name)
344
345#else /* !__ASSEMBLER__ */
346
347#if _CALL_ELF != 2
348
349#define PPC64_LOAD_FUNCPTR(ptr) \
350 "ld 12,0(" #ptr ")\n" \
351 "ld 2,8(" #ptr ")\n" \
352 "mtctr 12\n" \
353 "ld 11,16(" #ptr ")"
354
355#ifdef USE_PPC64_OVERLAPPING_OPD
356# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase"
357#else
358# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0"
359#endif
360
361#define ENTRY_1(name) \
362 ".type " BODY_PREFIX #name ",@function\n" \
363 ".globl " #name "\n" \
364 ".pushsection \".opd\",\"aw\"\n" \
365 ".p2align 3\n" \
366#name ":\n" \
367 OPD_ENT (name) "\n" \
368 ".popsection"
369
370#define DOT_PREFIX ""
371#define BODY_PREFIX ".LY"
372#define ENTRY_2(name) \
373 ".type " #name ",@function\n" \
374 ENTRY_1(name)
375#define END_2(name) \
376 ".size " #name ",.-" BODY_PREFIX #name "\n" \
377 ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name
378#define LOCALENTRY(name)
379
380#else /* _CALL_ELF */
381
382#define PPC64_LOAD_FUNCPTR(ptr) \
383 "mr 12," #ptr "\n" \
384 "mtctr 12"
385
386#define DOT_PREFIX ""
387#define BODY_PREFIX ""
388#define ENTRY_2(name) \
389 ".type " #name ",@function\n" \
390 ".globl " #name
391#define END_2(name) \
392 ".size " #name ",.-" #name
393#define LOCALENTRY(name) \
394 "1: addis 2,12,.TOC.-1b@ha\n" \
395 "addi 2,2,.TOC.-1b@l\n" \
396 ".localentry " #name ",.-" #name
397
398#endif /* _CALL_ELF */
399
400#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/powerpc/sysdep.h created+167
...@@ -0,0 +1,167 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP).
20 * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup.
21 */
22#define _SYSDEPS_SYSDEP_H 1
23#include <bits/hwcap.h>
24
25#define PPC_FEATURE_970 (PPC_FEATURE_POWER4 + PPC_FEATURE_HAS_ALTIVEC)
26
27#ifdef __ASSEMBLER__
28
29/* Symbolic names for the registers. The only portable way to write asm
30 code is to use number but this produces really unreadable code.
31 Therefore these symbolic names. */
32
33/* Integer registers. */
34#define r0 0
35#define r1 1
36#define r2 2
37#define r3 3
38#define r4 4
39#define r5 5
40#define r6 6
41#define r7 7
42#define r8 8
43#define r9 9
44#define r10 10
45#define r11 11
46#define r12 12
47#define r13 13
48#define r14 14
49#define r15 15
50#define r16 16
51#define r17 17
52#define r18 18
53#define r19 19
54#define r20 20
55#define r21 21
56#define r22 22
57#define r23 23
58#define r24 24
59#define r25 25
60#define r26 26
61#define r27 27
62#define r28 28
63#define r29 29
64#define r30 30
65#define r31 31
66
67/* Floating-point registers. */
68#define fp0 0
69#define fp1 1
70#define fp2 2
71#define fp3 3
72#define fp4 4
73#define fp5 5
74#define fp6 6
75#define fp7 7
76#define fp8 8
77#define fp9 9
78#define fp10 10
79#define fp11 11
80#define fp12 12
81#define fp13 13
82#define fp14 14
83#define fp15 15
84#define fp16 16
85#define fp17 17
86#define fp18 18
87#define fp19 19
88#define fp20 20
89#define fp21 21
90#define fp22 22
91#define fp23 23
92#define fp24 24
93#define fp25 25
94#define fp26 26
95#define fp27 27
96#define fp28 28
97#define fp29 29
98#define fp30 30
99#define fp31 31
100
101/* Condition code registers. */
102#define cr0 0
103#define cr1 1
104#define cr2 2
105#define cr3 3
106#define cr4 4
107#define cr5 5
108#define cr6 6
109#define cr7 7
110
111/* Vector registers. */
112#define v0 0
113#define v1 1
114#define v2 2
115#define v3 3
116#define v4 4
117#define v5 5
118#define v6 6
119#define v7 7
120#define v8 8
121#define v9 9
122#define v10 10
123#define v11 11
124#define v12 12
125#define v13 13
126#define v14 14
127#define v15 15
128#define v16 16
129#define v17 17
130#define v18 18
131#define v19 19
132#define v20 20
133#define v21 21
134#define v22 22
135#define v23 23
136#define v24 24
137#define v25 25
138#define v26 26
139#define v27 27
140#define v28 28
141#define v29 29
142#define v30 30
143#define v31 31
144
145#define VRSAVE 256
146
147/* The 32-bit words of a 64-bit dword are at these offsets in memory. */
148#if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN
149# define LOWORD 0
150# define HIWORD 4
151#else
152# define LOWORD 4
153# define HIWORD 0
154#endif
155
156/* The high 16-bit word of a 64-bit dword is at this offset in memory. */
157#if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN
158# define HISHORT 6
159#else
160# define HISHORT 0
161#endif
162
163/* This seems to always be the case on PPC. */
164#define ALIGNARG(log2) log2
165#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
166
167#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/pthread/allocalim.h deleted-32
...@@ -1,32 +0,0 @@
1/* Determine whether block of given size can be allocated on the stack or not.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#include <alloca.h>
20#include <limits.h>
21
22
23extern __always_inline
24int
25__libc_use_alloca (size_t size)
26{
27 return (__glibc_likely (__libc_alloca_cutoff (size))
28#ifdef PTHREAD_STACK_MIN
29 || __glibc_likely (size <= PTHREAD_STACK_MIN / 4)
30#endif
31 );
32}
libc/glibc/sysdeps/riscv/bits/endian.h created+5
...@@ -0,0 +1,5 @@
1#ifndef _ENDIAN_H
2# error "Never use <bits/endian.h> directly; include <endian.h> instead."
3#endif
4
5#define __BYTE_ORDER __LITTLE_ENDIAN
libc/glibc/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h created+68
...@@ -0,0 +1,68 @@
1/* Machine-specific pthread type layouts. RISC-V version.
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <endian.h>
23
24#if __riscv_xlen == 64
25# define __SIZEOF_PTHREAD_ATTR_T 56
26# define __SIZEOF_PTHREAD_MUTEX_T 40
27# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
28# define __SIZEOF_PTHREAD_COND_T 48
29# define __SIZEOF_PTHREAD_CONDATTR_T 4
30# define __SIZEOF_PTHREAD_RWLOCK_T 56
31# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
32# define __SIZEOF_PTHREAD_BARRIER_T 32
33# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
34#else
35# error "rv32i-based systems are not supported"
36#endif
37
38#define __PTHREAD_COMPAT_PADDING_MID
39#define __PTHREAD_COMPAT_PADDING_END
40#define __PTHREAD_MUTEX_LOCK_ELISION 0
41#define __PTHREAD_MUTEX_USE_UNION 0
42#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
43
44#define __LOCK_ALIGNMENT
45#define __ONCE_ALIGNMENT
46
47/* There is a lot of padding in this structure. While it's not strictly
48 necessary on RISC-V, we're going to leave it in to be on the safe side in
49 case it's needed in the future. Most other architectures have the padding,
50 so this gives us the same extensibility as everyone else has. */
51struct __pthread_rwlock_arch_t
52{
53 unsigned int __readers;
54 unsigned int __writers;
55 unsigned int __wrphase_futex;
56 unsigned int __writers_futex;
57 unsigned int __pad3;
58 unsigned int __pad4;
59 int __cur_writer;
60 int __shared;
61 unsigned long int __pad1;
62 unsigned long int __pad2;
63 unsigned int __flags;
64};
65
66#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
67
68#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/riscv/start.S created+86
...@@ -0,0 +1,86 @@
1/* Startup code compliant to the ELF RISC-V ABI.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <http://www.gnu.org/licenses/>. */
35
36#define __ASSEMBLY__ 1
37#include <entry.h>
38#include <sysdep.h>
39#include <sys/asm.h>
40
41/* The entry point's job is to call __libc_start_main. Per the ABI,
42 a0 contains the address of a function to be passed to atexit.
43 __libc_start_main wants this in a5. */
44
45ENTRY (ENTRY_POINT)
46 /* Terminate call stack by noting ra is undefined. Use a dummy
47 .cfi_label to force starting the FDE. */
48 .cfi_label .Ldummy
49 cfi_undefined (ra)
50 call .Lload_gp
51 mv a5, a0 /* rtld_fini. */
52 /* main may be in a shared library. */
53 la a0, main
54 REG_L a1, 0(sp) /* argc. */
55 addi a2, sp, SZREG /* argv. */
56 andi sp, sp, ALMASK /* Align stack. */
57 lla a3, __libc_csu_init
58 lla a4, __libc_csu_fini
59 mv a6, sp /* stack_end. */
60
61 call __libc_start_main@plt
62 ebreak
63END (ENTRY_POINT)
64
65/* Dynamic links need the global pointer to be initialized prior to calling
66 any shared library's initializers, so we use preinit_array to load it.
67 This doesn't cut it for static links, though, since the global pointer
68 needs to be initialized before calling __libc_start_main in that case.
69 So we redundantly initialize it at the beginning of _start. */
70
71.Lload_gp:
72.option push
73.option norelax
74 lla gp, __global_pointer$
75.option pop
76 ret
77
78 .section .preinit_array,"aw"
79 .dc.a .Lload_gp
80
81/* Define a symbol for the first piece of initialized data. */
82 .data
83 .globl __data_start
84__data_start:
85 .weak data_start
86 data_start = __data_start
libc/glibc/sysdeps/s390/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* s390 is big-endian */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __BIG_ENDIAN
libc/glibc/sysdeps/s390/nptl/bits/pthreadtypes-arch.h created+79
...@@ -0,0 +1,79 @@
1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <bits/wordsize.h>
22
23#if __WORDSIZE == 64
24# define __SIZEOF_PTHREAD_ATTR_T 56
25# define __SIZEOF_PTHREAD_MUTEX_T 40
26# define __SIZEOF_PTHREAD_RWLOCK_T 56
27# define __SIZEOF_PTHREAD_BARRIER_T 32
28#else
29# define __SIZEOF_PTHREAD_ATTR_T 36
30# define __SIZEOF_PTHREAD_MUTEX_T 24
31# define __SIZEOF_PTHREAD_RWLOCK_T 32
32# define __SIZEOF_PTHREAD_BARRIER_T 20
33#endif
34#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
35#define __SIZEOF_PTHREAD_CONDATTR_T 4
36#define __SIZEOF_PTHREAD_COND_T 48
37#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
38#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
39
40/* Definitions for internal mutex struct. */
41#define __PTHREAD_COMPAT_PADDING_MID
42#define __PTHREAD_COMPAT_PADDING_END
43#define __PTHREAD_MUTEX_LOCK_ELISION 1
44#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64)
45#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64)
46
47#define __LOCK_ALIGNMENT
48#define __ONCE_ALIGNMENT
49
50struct __pthread_rwlock_arch_t
51{
52 unsigned int __readers;
53 unsigned int __writers;
54 unsigned int __wrphase_futex;
55 unsigned int __writers_futex;
56 unsigned int __pad3;
57 unsigned int __pad4;
58#if __WORDSIZE == 64
59 int __cur_writer;
60 int __shared;
61 unsigned long int __pad1;
62 unsigned long int __pad2;
63 /* FLAGS must stay at this position in the structure to maintain
64 binary compatibility. */
65 unsigned int __flags;
66# else
67 unsigned char __pad1;
68 unsigned char __pad2;
69 unsigned char __shared;
70 /* FLAGS must stay at this position in the structure to maintain
71 binary compatibility. */
72 unsigned char __flags;
73 int __cur_writer;
74#endif
75};
76
77#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
78
79#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/s390/s390-32/crti.S created+104
...@@ -0,0 +1,104 @@
1/* Special .init and .fini section support for S/390.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .globl _init
60 .hidden _init
61 .type _init,@function
62 .align 4
63_init:
64 stm %r6,%r15,24(%r15)
65 bras %r13,1f
660:
67#if PREINIT_FUNCTION_WEAK
68 .long PREINIT_FUNCTION@GOT
69#else
70 .long PREINIT_FUNCTION-0b
71#endif
72 .long _GLOBAL_OFFSET_TABLE_-0b
731: lr %r1,%r15
74 ahi %r15,-96
75 st %r1,0(%r15)
76 l %r12,4(%r13)
77 ar %r12,%r13
78 l %r1,0(%r13)
79#if PREINIT_FUNCTION_WEAK
80 l %r1,0(%r1,%r12)
81 ltr %r1,%r1
82 je 2f
83#else
84 la %r1,0(%r1,%r13)
85#endif
86 basr %r14,%r1
87 .align 4,0x07
882:
89
90 .section .fini,"ax",@progbits
91 .globl _fini
92 .hidden _fini
93 .type _fini,@function
94 .align 4
95_fini:
96 stm %r6,%r15,24(%r15)
97 bras %r13,1f
980: .long _GLOBAL_OFFSET_TABLE_-0b
991: lr %r1,%r15
100 ahi %r15,-96
101 st %r1,0(%r15)
102 l %r12,0(%r13)
103 ar %r12,%r13
104 .align 4,0x07
libc/glibc/sysdeps/s390/s390-32/crtn.S created+47
...@@ -0,0 +1,47 @@
1/* Special .init and .fini section support for S/390.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 l %r4,152(%r15)
41 lm %r6,%r15,120(%r15)
42 br %r4
43
44 .section .fini,"ax",@progbits
45 l %r4,152(%r15)
46 lm %r6,%r15,120(%r15)
47 br %r4
libc/glibc/sysdeps/s390/s390-32/dl-sysdep.h created+23
...@@ -0,0 +1,23 @@
1/* System-specific settings for dynamic linker code. S/390 version.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
libc/glibc/sysdeps/s390/s390-32/start.S created+218
...@@ -0,0 +1,218 @@
1/* Startup code compliant to the ELF s390 ABI.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39/*
40 This is the canonical entry point, usually the first thing in the text
41 segment. Most registers' values are unspecified, except for:
42
43 %r14 Contains a function pointer to be registered with `atexit'.
44 This is how the dynamic linker arranges to have DT_FINI
45 functions called for shared libraries that have been loaded
46 before this code runs.
47
48 %r15 The stack contains the arguments and environment:
49 0(%r15) argc
50 4(%r15) argv[0]
51 ...
52 (4*argc)(%r15) NULL
53 (4*(argc+1))(%r15) envp[0]
54 ...
55 NULL
56*/
57
58 .text
59 .globl _start
60 .type _start,@function
61_start:
62 cfi_startproc
63 /* Mark r14 as undefined in order to stop unwinding here! */
64 cfi_undefined (r14)
65
66 /* Check if the kernel provides highgprs facility if needed by
67 the binary. */
68
69 lr %r6,%r15
70 la %r6,4(%r6) /* Skip the argument counter. */
71
72.L11: l %r5,0(%r6) /* Skip the argument vector. */
73 la %r6,4(%r6)
74 ltr %r5,%r5
75 jne .L11
76
77.L12: l %r5,0(%r6) /* Skip the environment vector. */
78 la %r6,4(%r6)
79 ltr %r5,%r5
80 jne .L12
81
82 /* Usually the auxiliary vector can be expected directly after
83 the environment variables. But we have to skip extra zeros
84 because the loader might have removed unsecure variables for
85 setuid programs. */
86
87.L26: l %r5,0(%r6)
88 la %r6,4(%r6)
89 ltr %r5,%r5
90 jz .L26
91
92 ahi %r6,-4
93
94 /* Obtain the needed values from the auxiliary vector. */
95
96 lhi %r7,16 /* AT_HWCAP */
97 lhi %r8,3 /* AT_PHDR */
98 lhi %r9,5 /* AT_PHNUM */
99 lhi %r2,4 /* AT_PHENT */
100.L13: l %r5,0(%r6)
101 clr %r5,%r7
102 jne .L15
103 l %r10,4(%r6) /* r10 = AT_HWCAP value. */
104.L15: clr %r5,%r8
105 jne .L16
106 l %r11,4(%r6) /* r11 = AT_PHDR value. */
107.L16: clr %r5,%r9
108 jne .L17
109 l %r12,4(%r6) /* r12 = AT_PHNUM value. */
110.L17: clr %r5,%r2
111 jne .L18
112 l %r0,4(%r6) /* r0 = AT_PHENT value. */
113.L18: ltr %r5,%r5
114 la %r6,8(%r6)
115 jnz .L13
116
117 /* Locate the ELF header by looking for the first PT_LOAD
118 segment with a p_offset of zero. */
119
120 lr %r4,%r11 /* Backup AT_PHDR. */
121 lhi %r7,1 /* PT_LOAD id */
122 lhi %r8,0
123.L19: cl %r7,0(%r4) /* p_type == PT_LOAD? */
124 jne .L20
125 cl %r8,4(%r4) /* p_offset == 0? */
126 jne .L20
127 l %r9,8(%r4) /* r9 = PT_LOAD.p_vaddr <- ELF header address */
128 j .L24
129.L20: alr %r4,%r0 /* r4 += AT_PHENT value */
130 brct %r12,.L19
131
132 j .+2 /* Trap, there must be such a phdr. */
133
134.L24: lr %r4,%r11 /* Backup AT_PHDR. */
135 lhi %r2,6 /* PT_PHDR id */
136.L23: cl %r2,0(%r4)
137 jne .L22
138 l %r3,8(%r4) /* r3 = PT_PHDR p_vaddr */
139 j .L25
140.L22: alr %r4,%r0 /* r4 += AT_PHENT value */
141 brct %r12,.L23
142
143 j .L14 /* No PT_PHDR found - skip checking. */
144
145.L25: slr %r11,%r3 /* AT_PHDR - PT_PHDR.p_vaddr (relocation offset)*/
146 alr %r9,%r11 /* PT_LOAD.p_vaddr += relocation offset */
147
148 l %r5,36(%r9) /* Load the e_flags field. */
149 tml %r5,1
150 jz .L14 /* Binary does not require highgprs facility. */
151
152 tml %r10,512 /* Check the AT_HWCAP value. */
153 jz 2 /* Trap if no highgprs facility available. */
154.L14:
155
156 /* Setup pointer to literal pool of _start */
157 basr %r13,0
158.L0: ahi %r13,.Llit-.L0
159
160 /* load argc and argv from stack */
161 la %r4,4(%r15) # get argv
162 l %r3,0(%r15) # get argc
163
164 /* align the stack to a double word boundary */
165 lhi %r0,-8
166 nr %r15,%r0
167
168 /* Setup a stack frame and a parameter area */
169 ahi %r15,-104 # make room on stack
170 xc 0(4,%r15),0(%r15) # clear back-chain
171
172 /* set up arguments for __libc_start_main:
173 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
174 Note that envp will be determined later in __libc_start_main
175 */
176 stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
177 la %r7,96(%r15)
178 l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
179 l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
180 l %r2,.L3-.Llit(%r13) # load pointer to main
181 l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
182#ifdef PIC
183 l %r12,.L5-.Llit(%r13) # load .got pointer
184 la %r6,0(%r13,%r6)
185 la %r5,0(%r13,%r5)
186 la %r12,0(%r13,%r12)
187 l %r2,0(%r12,%r2)
188 la %r1,0(%r13,%r1)
189#endif
190
191 /* ok, now branch to the libc main routine */
192 basr %r14,%r1
193
194 /* crash if __libc_start_main returns */
195 .word 0
196
197 cfi_endproc
198.Llit:
199#ifndef PIC
200.L1: .long __libc_csu_init
201.L2: .long __libc_csu_fini
202.L3: .long main
203.L4: .long __libc_start_main
204#else
205.L1: .long __libc_csu_init-.Llit
206.L2: .long __libc_csu_fini-.Llit
207.L3: .long main@GOT
208.L4: .long __libc_start_main@plt-.Llit
209.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
210#endif
211
212/* Define a symbol for the first piece of initialized data. */
213 .data
214 .globl __data_start
215__data_start:
216 .long 0
217 .weak data_start
218 data_start = __data_start
libc/glibc/sysdeps/s390/s390-32/symbol-hacks.h created+21
...@@ -0,0 +1,21 @@
1/* Hacks needed for symbol manipulation. s390 version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
20
21#include_next "symbol-hacks.h"
libc/glibc/sysdeps/s390/s390-32/sysdep.h created+101
...@@ -0,0 +1,101 @@
1/* Assembler macros for s390.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <sysdeps/generic/sysdep.h>
21
22#ifdef __ASSEMBLER__
23
24/* Syntactic details of assembler. */
25
26/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
27#define ALIGNARG(log2) 1<<log2
28#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
29
30
31/* Define an entry point visible from C. */
32#define ENTRY(name) \
33 .globl C_SYMBOL_NAME(name); \
34 .type C_SYMBOL_NAME(name),@function; \
35 .align ALIGNARG(2); \
36 C_LABEL(name) \
37 cfi_startproc; \
38 CALL_MCOUNT
39
40#undef END
41#define END(name) \
42 cfi_endproc; \
43 ASM_SIZE_DIRECTIVE(name) \
44
45/* If compiled for profiling, call `mcount' at the start of each function. */
46#ifdef PROF
47#ifdef PIC
48#define CALL_MCOUNT \
49 lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \
50 lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \
51 basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ;
52#else
53#define CALL_MCOUNT \
54 lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \
55 l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \
56 .data ; .align 4 ; 0: .long 0 ; .text ;
57#endif
58#else
59#define CALL_MCOUNT /* Do nothing. */
60#endif
61
62/* Since C identifiers are not normally prefixed with an underscore
63 on this system, the asm identifier `syscall_error' intrudes on the
64 C name space. Make sure we use an innocuous name. */
65#define syscall_error __syscall_error
66#define mcount _mcount
67
68#undef PSEUDO
69#define PSEUDO(name, syscall_name, args) \
70lose: SYSCALL_PIC_SETUP \
71 basr %r1,0; \
720: al %r1,1f-0b(%r1); \
73 br %r1; \
741: .long JUMPTARGET(syscall_error) - 0b; \
75 .globl syscall_error; \
76 ENTRY (name) \
77 DO_CALL (syscall_name, args); \
78 jm lose
79
80#undef PSEUDO_END
81#define PSEUDO_END(name) \
82 END (name)
83
84#undef JUMPTARGET
85#ifdef SHARED
86#define JUMPTARGET(name) name##@PLT
87#define SYSCALL_PIC_SETUP \
88 bras %r12,1f; \
890: .long _GLOBAL_OFFSET_TABLE_-0b; \
901: al %r12,0(%r12)
91#else
92#define JUMPTARGET(name) name
93#define SYSCALL_PIC_SETUP /* Nothing. */
94#endif
95
96/* Local label name for asm code. */
97#ifndef L
98#define L(name) .L##name
99#endif
100
101#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/s390/s390-64/crti.S created+93
...@@ -0,0 +1,93 @@
1/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37/* crti.S puts a function prologue at the beginning of the .init and
38 .fini sections and defines global symbols for those addresses, so
39 they can be called as functions. The symbols _init and _fini are
40 magic and cause the linker to emit DT_INIT and DT_FINI. */
41
42#include <libc-symbols.h>
43#include <sysdep.h>
44
45#ifndef PREINIT_FUNCTION
46# define PREINIT_FUNCTION __gmon_start__
47#endif
48
49#ifndef PREINIT_FUNCTION_WEAK
50# define PREINIT_FUNCTION_WEAK 1
51#endif
52
53#if PREINIT_FUNCTION_WEAK
54 weak_extern (PREINIT_FUNCTION)
55#else
56 .hidden PREINIT_FUNCTION
57#endif
58
59 .section .init,"ax",@progbits
60 .align 4
61 .globl _init
62 .hidden _init
63 .type _init,@function
64_init:
65 stmg %r6,%r15,48(%r15)
66 lgr %r1,%r15
67 aghi %r15,-160
68 stg %r1,0(%r15)
69 larl %r12,_GLOBAL_OFFSET_TABLE_
70#if PREINIT_FUNCTION_WEAK
71 larl %r1,PREINIT_FUNCTION@GOTENT
72 lg %r1,0(%r1)
73 ltgr %r1,%r1
74 je 1f
75 basr %r14,%r1
76#else
77 brasl %r14,PREINIT_FUNCTION
78#endif
79 .align 4,0x07
801:
81
82 .section .fini,"ax",@progbits
83 .align 4
84 .globl _fini
85 .hidden _fini
86 .type _fini,@function
87_fini:
88 stmg %r6,%r15,48(%r15)
89 lgr %r1,%r15
90 aghi %r15,-160
91 stg %r1,0(%r15)
92 larl %r12,_GLOBAL_OFFSET_TABLE_
93 .align 4,0x07
libc/glibc/sysdeps/s390/s390-64/crtn.S created+50
...@@ -0,0 +1,50 @@
1/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37/* crtn.S puts function epilogues in the .init and .fini sections
38 corresponding to the prologues in crti.S. */
39
40 .section .init
41 .align 4
42 lg %r4,272(%r15)
43 lmg %r6,%r15,208(%r15)
44 br %r4
45
46 .section .fini
47 .align 4
48 lg %r4,272(%r15)
49 lmg %r6,%r15,208(%r15)
50 br %r4
libc/glibc/sysdeps/s390/s390-64/start.S created+107
...@@ -0,0 +1,107 @@
1/* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39/*
40 This is the canonical entry point, usually the first thing in the text
41 segment. Most registers' values are unspecified, except for:
42
43 %r14 Contains a function pointer to be registered with `atexit'.
44 This is how the dynamic linker arranges to have DT_FINI
45 functions called for shared libraries that have been loaded
46 before this code runs.
47
48 %r15 The stack contains the arguments and environment:
49 0(%r15) argc
50 8(%r15) argv[0]
51 ...
52 (8*argc)(%r15) NULL
53 (8*(argc+1))(%r15) envp[0]
54 ...
55 NULL
56*/
57
58 .text
59 .globl _start
60 .type _start,@function
61_start:
62 cfi_startproc
63 /* Mark r14 as undefined in order to stop unwinding here! */
64 cfi_undefined (r14)
65 /* Load argc and argv from stack. */
66 la %r4,8(%r15) # get argv
67 lg %r3,0(%r15) # get argc
68
69 /* Align the stack to a double word boundary. */
70 lghi %r0,-16
71 ngr %r15,%r0
72
73 /* Setup a stack frame and a parameter area. */
74 aghi %r15,-176 # make room on stack
75 xc 0(8,%r15),0(%r15) # clear back-chain
76
77 /* Set up arguments for __libc_start_main:
78 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
79 Note that envp will be determined later in __libc_start_main.
80 */
81 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
82 la %r7,160(%r15)
83 larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
84 larl %r5,__libc_csu_init # load pointer to __libc_csu_init
85
86 /* Ok, now branch to the libc main routine. */
87#ifdef PIC
88 larl %r2,main@GOTENT # load pointer to main
89 lg %r2,0(%r2)
90 brasl %r14,__libc_start_main@plt
91#else
92 larl %r2,main # load pointer to main
93 brasl %r14,__libc_start_main
94#endif
95
96 /* Crash if __libc_start_main returns. */
97 .word 0
98
99 cfi_endproc
100
101 /* Define a symbol for the first piece of initialized data. */
102 .data
103 .globl __data_start
104__data_start:
105 .long 0
106 .weak data_start
107 data_start = __data_start
libc/glibc/sysdeps/s390/s390-64/sysdep.h created+94
...@@ -0,0 +1,94 @@
1/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <sysdeps/generic/sysdep.h>
21
22#ifdef __ASSEMBLER__
23
24/* Syntactic details of assembler. */
25
26/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
27#define ALIGNARG(log2) 1<<log2
28#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
29
30
31/* Define an entry point visible from C. */
32#define ENTRY(name) \
33 .globl C_SYMBOL_NAME(name); \
34 .type C_SYMBOL_NAME(name),@function; \
35 .align ALIGNARG(2); \
36 C_LABEL(name) \
37 cfi_startproc; \
38 CALL_MCOUNT
39
40#undef END
41#define END(name) \
42 cfi_endproc; \
43 ASM_SIZE_DIRECTIVE(name) \
44
45/* If compiled for profiling, call `mcount' at the start of each function. */
46#ifdef PROF
47#ifdef PIC
48#define CALL_MCOUNT \
49 lgr 0,14 ; larl 1,0f ; brasl 14,_mcount@PLT ; lgr 14,0 ; \
50 .data ; .align 4 ; 0: .long 0 ; .text ;
51#else
52#define CALL_MCOUNT \
53 lgr 0,14 ; larl 1,0f ; brasl 14,_mcount ; lgr 14,0 ; \
54 .data ; .align 4 ; 0: .long 0 ; .text ;
55#endif
56#else
57#define CALL_MCOUNT /* Do nothing. */
58#endif
59
60/* Since C identifiers are not normally prefixed with an underscore
61 on this system, the asm identifier `syscall_error' intrudes on the
62 C name space. Make sure we use an innocuous name. */
63#define syscall_error __syscall_error
64#define mcount _mcount
65
66#undef PSEUDO
67#define PSEUDO(name, syscall_name, args) \
68lose: SYSCALL_PIC_SETUP \
69 jg JUMPTARGET(syscall_error); \
70 .globl syscall_error; \
71 ENTRY (name) \
72 DO_CALL (syscall_name, args); \
73 jm lose
74
75#undef PSEUDO_END
76#define PSEUDO_END(name) \
77 END (name)
78
79#undef JUMPTARGET
80#ifdef SHARED
81#define JUMPTARGET(name) name##@PLT
82#define SYSCALL_PIC_SETUP \
83 larl %r12,_GLOBAL_OFFSET_TABLE_
84#else
85#define JUMPTARGET(name) name
86#define SYSCALL_PIC_SETUP /* Nothing. */
87#endif
88
89/* Local label name for asm code. */
90#ifndef L
91#define L(name) .L##name
92#endif
93
94#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/sh/bits/endian.h created+13
...@@ -0,0 +1,13 @@
1/* SH is bi-endian but with a big-endian FPU. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#ifdef __LITTLE_ENDIAN__
8#define __BYTE_ORDER __LITTLE_ENDIAN
9#define __FLOAT_WORD_ORDER __LITTLE_ENDIAN
10#else
11#define __BYTE_ORDER __BIG_ENDIAN
12#define __FLOAT_WORD_ORDER __BIG_ENDIAN
13#endif
libc/glibc/sysdeps/sh/crti.S created+122
...@@ -0,0 +1,122 @@
1/* Special .init and .fini section support for SH.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 5
60 .global _init
61 .hidden _init
62 .type _init, @function
63_init:
64 mov.l r12,@-r15
65 mova .L12,r0
66 mov.l .L12,r12
67 mov.l r14,@-r15
68 add r0,r12
69 sts.l pr,@-r15
70#if PREINIT_FUNCTION_WEAK
71 mov.l .L13,r0
72 mov.l @(r0,r12),r1
73 tst r1,r1
74 bt/s .L8
75 mov r15,r14
76 mov.l .L14,r1
77 bsrf r1
78.LPCS0:
79 nop
80.L8:
81#else
82 mova .L13,r0
83 mov.l .L13,r1
84 add r0,r1
85 jsr @r1
86 mov r15,r14
87#endif
88 bra 1f
89 nop
90 .align 2
91.L12:
92 .long _GLOBAL_OFFSET_TABLE_
93#if PREINIT_FUNCTION_WEAK
94.L13:
95 .long PREINIT_FUNCTION@GOT
96.L14:
97 .long PREINIT_FUNCTION@PLT-(.LPCS0+2-(.))
98#else
99.L13:
100 .long PREINIT_FUNCTION@PLT
101#endif
1021:
103
104 .section .fini,"ax",@progbits
105 .align 5
106 .global _fini
107 .hidden _fini
108 .type _fini, @function
109_fini:
110 mov.l r12,@-r15
111 mova .L19,r0
112 mov.l r14,@-r15
113 sts.l pr,@-r15
114 mov.l .L19,r12
115 mov r15,r14
116 add r0,r12
117 bra 0f
118 nop
119 .align 2
120.L19:
121 .long _GLOBAL_OFFSET_TABLE_
1220:
libc/glibc/sysdeps/sh/crtn.S created+53
...@@ -0,0 +1,53 @@
1/* Special .init and .fini section support for SH.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 mov r14,r15
41 lds.l @r15+,pr
42 mov.l @r15+,r14
43 mov.l @r15+,r12
44 rts
45 nop
46
47 .section .fini,"ax",@progbits
48 mov r14,r15
49 lds.l @r15+,pr
50 mov.l @r15+,r14
51 mov.l @r15+,r12
52 rts
53 nop
libc/glibc/sysdeps/sh/nptl/bits/pthreadtypes-arch.h created+71
...@@ -0,0 +1,71 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <endian.h>
22
23#define __SIZEOF_PTHREAD_ATTR_T 36
24#define __SIZEOF_PTHREAD_MUTEX_T 24
25#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
26#define __SIZEOF_PTHREAD_COND_T 48
27#define __SIZEOF_PTHREAD_CONDATTR_T 4
28#define __SIZEOF_PTHREAD_RWLOCK_T 32
29#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
30#define __SIZEOF_PTHREAD_BARRIER_T 20
31#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
32
33/* Definitions for internal mutex struct. */
34#define __PTHREAD_COMPAT_PADDING_MID
35#define __PTHREAD_COMPAT_PADDING_END
36#define __PTHREAD_MUTEX_LOCK_ELISION 0
37#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
38#define __PTHREAD_MUTEX_USE_UNION 1
39
40#define __LOCK_ALIGNMENT
41#define __ONCE_ALIGNMENT
42
43struct __pthread_rwlock_arch_t
44{
45 unsigned int __readers;
46 unsigned int __writers;
47 unsigned int __wrphase_futex;
48 unsigned int __writers_futex;
49 unsigned int __pad3;
50 unsigned int __pad4;
51#if __BYTE_ORDER == __BIG_ENDIAN
52 unsigned char __pad1;
53 unsigned char __pad2;
54 unsigned char __shared;
55 /* FLAGS must stay at this position in the structure to maintain
56 binary compatibility. */
57 unsigned char __flags;
58#else
59 /* FLAGS must stay at this position in the structure to maintain
60 binary compatibility. */
61 unsigned char __flags;
62 unsigned char __shared;
63 unsigned char __pad1;
64 unsigned char __pad2;
65#endif
66 unsigned long int __cur_writer;
67};
68
69#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
70
71#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/sh/start.S created+111
...@@ -0,0 +1,111 @@
1/* Startup code for SH & ELF.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* This is the canonical entry point, usually the first thing in the text
37 segment.
38
39 Note that the code in the .init section has already been run.
40 This includes _init and _libc_init
41
42
43 At this entry point, most registers' values are unspecified, except:
44
45 r4 Contains a function pointer to be registered with `atexit'.
46 This is how the dynamic linker arranges to have DT_FINI
47 functions called for shared libraries that have been loaded
48 before this code runs.
49
50 sp The stack contains the arguments and environment:
51 0(sp) argc
52 4(sp) argv[0]
53 ...
54 (4*argc)(sp) NULL
55 (4*(argc+1))(sp) envp[0]
56 ...
57 NULL
58*/
59
60 .text
61 .globl _start
62 .type _start,@function
63_start:
64 /* Clear the frame pointer since this is the outermost frame. */
65 mov #0, r14
66
67 /* Pop argc off the stack and save a pointer to argv */
68 mov.l @r15+,r5
69 mov r15, r6
70
71 /* Push the last arguments to main() onto the stack */
72 mov.l r4,@-r15
73 mov.l L_fini,r0
74 mov.l r0,@-r15
75
76 /* Set up the other arguments for main() that go in registers */
77 mov.l L_main,r4
78 mov.l L_init,r7
79
80 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
81
82 /* Let the libc call main and exit with its return code. */
83 mov.l L_libc_start_main,r1
84 jsr @r1
85 nop
86 /* should never get here....*/
87 mov.l L_abort,r1
88 jsr @r1
89 nop
90 .align 2
91L_main:
92 .long main
93L_init:
94 .long __libc_csu_init
95L_fini:
96 .long __libc_csu_fini
97L_libc_start_main:
98 .long __libc_start_main
99L_abort:
100 .long abort
101/* Define a symbol for the first piece of initialized data. */
102 .data
103 .globl __data_start
104__data_start:
105 .long 0
106 .weak data_start
107 data_start = __data_start
108 .global __fpscr_values
109__fpscr_values:
110 .long 0
111 .long 0x80000
libc/glibc/sysdeps/sh/sysdep.h created+75
...@@ -0,0 +1,75 @@
1/* Assembler macros for SH.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/generic/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Syntactic details of assembler. */
24
25#define ALIGNARG(log2) log2
26#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
27
28#ifdef SHARED
29#define PLTJMP(_x) _x##@PLT
30#else
31#define PLTJMP(_x) _x
32#endif
33
34
35/* Define an entry point visible from C. */
36#define ENTRY(name) \
37 .globl C_SYMBOL_NAME(name); \
38 .type C_SYMBOL_NAME(name),@function; \
39 .align ALIGNARG(5); \
40 C_LABEL(name) \
41 cfi_startproc; \
42 CALL_MCOUNT
43
44#undef END
45#define END(name) \
46 cfi_endproc; \
47 ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(name))
48
49/* If compiled for profiling, call `mcount' at the start of each function. */
50#ifdef PROF
51#define CALL_MCOUNT \
52 mov.l 1f,r1; \
53 sts.l pr,@-r15; \
54 cfi_adjust_cfa_offset (4); \
55 cfi_rel_offset (pr, 0); \
56 mova 2f,r0; \
57 jmp @r1; \
58 lds r0,pr; \
59 .align 2; \
601: .long mcount; \
612: lds.l @r15+,pr; \
62 cfi_adjust_cfa_offset (-4); \
63 cfi_restore (pr)
64
65#else
66#define CALL_MCOUNT /* Do nothing. */
67#endif
68
69/* Since C identifiers are not normally prefixed with an underscore
70 on this system, the asm identifier `syscall_error' intrudes on the
71 C name space. Make sure we use an innocuous name. */
72#define syscall_error __syscall_error
73#define mcount _mcount
74
75#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/sparc/bits/endian.h created+12
...@@ -0,0 +1,12 @@
1/* Sparc is big-endian, but v9 supports endian conversion on loads/stores
2 and GCC supports such a mode. Be prepared. */
3
4#ifndef _ENDIAN_H
5# error "Never use <bits/endian.h> directly; include <endian.h> instead."
6#endif
7
8#ifdef __LITTLE_ENDIAN__
9# define __BYTE_ORDER __LITTLE_ENDIAN
10#else
11# define __BYTE_ORDER __BIG_ENDIAN
12#endif
libc/glibc/sysdeps/sparc/crti.S created+95
...@@ -0,0 +1,95 @@
1/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58#ifdef __arch64__
59#define STACKFRAME_SIZE 176
60#define GOT_LOAD ldx
61#else
62#define STACKFRAME_SIZE 96
63#define GOT_LOAD ld
64#endif
65
66 .section .init,"ax",@progbits
67 .p2align 2
68 .globl _init
69 .hidden _init
70 .type _init, @function
71_init:
72 save %sp, -STACKFRAME_SIZE, %sp
73#if PREINIT_FUNCTION_WEAK
74 SETUP_PIC_REG(l7)
75 sethi %gdop_hix22(PREINIT_FUNCTION), %g1
76 xor %g1, %gdop_lox10(PREINIT_FUNCTION), %g1
77 GOT_LOAD [%l7 + %g1], %g1, %gdop(PREINIT_FUNCTION)
78 cmp %g1, 0
79 be 1f
80 nop
81 call PREINIT_FUNCTION
82 nop
831:
84#else
85 call PREINIT_FUNCTION
86 nop
87#endif
88
89 .section .fini,"ax",@progbits
90 .p2align 2
91 .globl _fini
92 .hidden _fini
93 .type _fini, @function
94_fini:
95 save %sp, -STACKFRAME_SIZE, %sp
libc/glibc/sysdeps/sparc/crtn.S created+45
...@@ -0,0 +1,45 @@
1/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 jmp %i7 + 8
41 restore
42
43 .section .fini,"ax",@progbits
44 jmp %i7 + 8
45 restore
libc/glibc/sysdeps/sparc/dl-dtprocnum.h created+21
...@@ -0,0 +1,21 @@
1/* Configuration of lookup functions. SPARC version.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Number of extra dynamic section entries for this architecture. By
20 default there are none. */
21#define DT_THISPROCNUM DT_SPARC_NUM
libc/glibc/sysdeps/sparc/dl-sysdep.h created+23
...@@ -0,0 +1,23 @@
1/* System-specific settings for dynamic linker code. SPARC version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* _dl_argv cannot be attribute_relro, because _dl_start_user
22 might write into it after _dl_start returns. */
23#define DL_ARGV_NOT_RELRO 1
libc/glibc/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h created+81
...@@ -0,0 +1,81 @@
1/* Machine-specific pthread type layouts. SPARC version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <bits/wordsize.h>
23
24#if __WORDSIZE == 64
25# define __SIZEOF_PTHREAD_ATTR_T 56
26# define __SIZEOF_PTHREAD_MUTEX_T 40
27# define __SIZEOF_PTHREAD_CONDATTR_T 4
28# define __SIZEOF_PTHREAD_RWLOCK_T 56
29# define __SIZEOF_PTHREAD_BARRIER_T 32
30#else
31# define __SIZEOF_PTHREAD_ATTR_T 36
32# define __SIZEOF_PTHREAD_MUTEX_T 24
33# define __SIZEOF_PTHREAD_CONDATTR_T 4
34# define __SIZEOF_PTHREAD_RWLOCK_T 32
35# define __SIZEOF_PTHREAD_BARRIER_T 20
36#endif
37#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
38#define __SIZEOF_PTHREAD_COND_T 48
39#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
40#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
41
42/* Definitions for internal mutex struct. */
43#define __PTHREAD_COMPAT_PADDING_MID
44#define __PTHREAD_COMPAT_PADDING_END
45#define __PTHREAD_MUTEX_LOCK_ELISION 0
46#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64)
47#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64)
48
49#define __LOCK_ALIGNMENT
50#define __ONCE_ALIGNMENT
51
52struct __pthread_rwlock_arch_t
53{
54 unsigned int __readers;
55 unsigned int __writers;
56 unsigned int __wrphase_futex;
57 unsigned int __writers_futex;
58 unsigned int __pad3;
59 unsigned int __pad4;
60#if __WORDSIZE == 64
61 int __cur_writer;
62 int __shared;
63 unsigned long int __pad1;
64 unsigned long int __pad2;
65 /* FLAGS must stay at this position in the structure to maintain
66 binary compatibility. */
67 unsigned int __flags;
68#else
69 unsigned char __pad1;
70 unsigned char __pad2;
71 unsigned char __shared;
72 /* FLAGS must stay at this position in the structure to maintain
73 binary compatibility. */
74 unsigned char __flags;
75 int __cur_writer;
76#endif
77};
78
79#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
80
81#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/sparc/sparc32/start.S created+99
...@@ -0,0 +1,99 @@
1/* Startup code for elf32-sparc
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39
40 .section ".text"
41 .align 4
42 .global _start
43 .type _start,#function
44_start:
45#ifdef PIC
46 SETUP_PIC_REG(l7)
47#endif
48
49 /* Terminate the stack frame, and reserve space for functions to
50 drop their arguments. */
51 mov %g0, %fp
52 sub %sp, 6*4, %sp
53
54 /* Extract the arguments and environment as encoded on the stack. The
55 argument info starts after one register window (16 words) past the SP. */
56 ld [%sp+22*4], %o1
57 add %sp, 23*4, %o2
58
59 /* Load the addresses of the user entry points. */
60#ifndef PIC
61 sethi %hi(main), %o0
62 sethi %hi(__libc_csu_init), %o3
63 sethi %hi(__libc_csu_fini), %o4
64 or %o0, %lo(main), %o0
65 or %o3, %lo(__libc_csu_init), %o3
66 or %o4, %lo(__libc_csu_fini), %o4
67#else
68 sethi %gdop_hix22(main), %o0
69 sethi %gdop_hix22(__libc_csu_init), %o3
70 sethi %gdop_hix22(__libc_csu_fini), %o4
71 xor %o0, %gdop_lox10(main), %o0
72 xor %o3, %gdop_lox10(__libc_csu_init), %o3
73 xor %o4, %gdop_lox10(__libc_csu_fini), %o4
74 ld [%l7 + %o0], %o0, %gdop(main)
75 ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
76 ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
77#endif
78
79 /* When starting a binary via the dynamic linker, %g1 contains the
80 address of the shared library termination function, which will be
81 registered with atexit(). If we are statically linked, this will
82 be NULL. */
83 mov %g1, %o5
84
85 /* Let libc do the rest of the initialization, and call main. */
86 call __libc_start_main
87 nop
88
89 /* Die very horribly if exit returns. */
90 unimp
91
92 .size _start, .-_start
93
94/* Define a symbol for the first piece of initialized data. */
95 .data
96 .globl __data_start
97__data_start:
98 .long 0
99weak_alias (__data_start, data_start)
libc/glibc/sysdeps/sparc/sparc64/start.S created+100
...@@ -0,0 +1,100 @@
1/* Startup code for elf64-sparc
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37#include <sysdep.h>
38
39
40 .section ".text"
41 .align 4
42 .global _start
43 .type _start,#function
44_start:
45#ifdef PIC
46 SETUP_PIC_REG(l7)
47#endif
48
49 /* Terminate the stack frame, and reserve space for functions to
50 drop their arguments. */
51 mov %g0, %fp
52 sub %sp, 6*8, %sp
53
54 /* Extract the arguments and environment as encoded on the stack. The
55 argument info starts after one register window (16 words) past the SP,
56 plus the bias we added, plus the magic v9 STACK_BIAS. */
57 ldx [%sp+STACK_BIAS+22*8], %o1
58 add %sp, STACK_BIAS+23*8, %o2
59
60 /* Load the addresses of the user entry points. */
61#ifndef PIC
62 sethi %hi(main), %o0
63 sethi %hi(__libc_csu_init), %o3
64 sethi %hi(__libc_csu_fini), %o4
65 or %o0, %lo(main), %o0
66 or %o3, %lo(__libc_csu_init), %o3
67 or %o4, %lo(__libc_csu_fini), %o4
68#else
69 sethi %gdop_hix22(main), %o0
70 sethi %gdop_hix22(__libc_csu_init), %o3
71 sethi %gdop_hix22(__libc_csu_fini), %o4
72 xor %o0, %gdop_lox10(main), %o0
73 xor %o3, %gdop_lox10(__libc_csu_init), %o3
74 xor %o4, %gdop_lox10(__libc_csu_fini), %o4
75 ldx [%l7 + %o0], %o0, %gdop(main)
76 ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
77 ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
78#endif
79
80 /* When starting a binary via the dynamic linker, %g1 contains the
81 address of the shared library termination function, which will be
82 registered with atexit(). If we are statically linked, this will
83 be NULL. */
84 mov %g1, %o5
85
86 /* Let libc do the rest of the initialization, and call main. */
87 call __libc_start_main
88 nop
89
90 /* Die very horribly if exit returns. */
91 illtrap 0
92
93 .size _start, .-_start
94
95/* Define a symbol for the first piece of initialized data. */
96 .data
97 .globl __data_start
98__data_start:
99 .long 0
100weak_alias (__data_start, data_start)
libc/glibc/sysdeps/sparc/sysdep.h created+82
...@@ -0,0 +1,82 @@
1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#define _SYSDEPS_SYSDEP_H 1
19#include <bits/hwcap.h>
20
21#ifdef __ASSEMBLER__
22
23#define SPARC_PIC_THUNK(reg) \
24 .ifndef __sparc_get_pc_thunk.reg; \
25 .section .text.__sparc_get_pc_thunk.reg,"axG",@progbits,__sparc_get_pc_thunk.reg,comdat; \
26 .align 32; \
27 .weak __sparc_get_pc_thunk.reg; \
28 .hidden __sparc_get_pc_thunk.reg; \
29 .type __sparc_get_pc_thunk.reg, #function; \
30__sparc_get_pc_thunk.reg: \
31 jmp %o7 + 8; \
32 add %o7, %reg, %##reg; \
33 .previous; \
34 .endif;
35
36/* The "-4" and "+4" offsets against _GLOBAL_OFFSET_TABLE_ are
37 critical since they represent the offset from the thunk call to the
38 instruction containing the _GLOBAL_OFFSET_TABLE_ reference.
39 Therefore these instructions cannot be moved around without
40 appropriate adjustments to those offsets.
41
42 Furthermore, these expressions are special in another regard. When
43 the assembler sees a reference to _GLOBAL_OFFSET_TABLE_ inside of
44 a %hi() or %lo(), it emits a PC-relative relocation. This causes
45 R_SPARC_HI22 to turn into R_SPARC_PC22, and R_SPARC_LO10 to turn into
46 R_SPARC_PC10, respectively.
47
48 Even when v9 we use a call sequence instead of using "rd %pc" because
49 RDPC is extremely expensive and incurs a full pipeline flush. */
50
51#define SPARC_PIC_THUNK_CALL(reg) \
52 sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
53 call __sparc_get_pc_thunk.reg; \
54 or %##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg;
55
56#define SETUP_PIC_REG(reg) \
57 SPARC_PIC_THUNK(reg) \
58 SPARC_PIC_THUNK_CALL(reg)
59
60#define SETUP_PIC_REG_LEAF(reg, tmp) \
61 SPARC_PIC_THUNK(reg) \
62 mov %o7, %##tmp; \
63 SPARC_PIC_THUNK_CALL(reg); \
64 mov %##tmp, %o7;
65
66#undef ENTRY
67#define ENTRY(name) \
68 .align 4; \
69 .global C_SYMBOL_NAME(name); \
70 .type name, @function; \
71C_LABEL(name) \
72 cfi_startproc;
73
74#undef END
75#define END(name) \
76 cfi_endproc; \
77 .size name, . - name
78
79#undef LOC
80#define LOC(name) .L##name
81
82#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/unix/alpha/sysdep.h created+382
...@@ -0,0 +1,382 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Brendan Kehoe (brendan@zen.org).
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/sysdep.h>
20#include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
21
22#ifdef __ASSEMBLER__
23
24#ifdef __linux__
25# include <alpha/regdef.h>
26#else
27# include <regdef.h>
28#endif
29
30#define __LABEL(x) x##:
31
32#define LEAF(name, framesize) \
33 .globl name; \
34 .align 4; \
35 .ent name, 0; \
36 __LABEL(name) \
37 .frame sp, framesize, ra
38
39#define ENTRY(name) \
40 .globl name; \
41 .align 4; \
42 .ent name, 0; \
43 __LABEL(name) \
44 .frame sp, 0, ra
45
46/* Mark the end of function SYM. */
47#undef END
48#define END(sym) .end sym
49
50#ifdef PROF
51# define PSEUDO_PROF \
52 .set noat; \
53 lda AT, _mcount; \
54 jsr AT, (AT), _mcount; \
55 .set at
56#else
57# define PSEUDO_PROF
58#endif
59
60#ifdef PROF
61# define PSEUDO_PROLOGUE \
62 .frame sp, 0, ra; \
63 ldgp gp,0(pv); \
64 PSEUDO_PROF; \
65 .prologue 1
66#elif defined PIC
67# define PSEUDO_PROLOGUE \
68 .frame sp, 0, ra; \
69 .prologue 0
70#else
71# define PSEUDO_PROLOGUE \
72 .frame sp, 0, ra; \
73 ldgp gp,0(pv); \
74 .prologue 1
75#endif /* PROF */
76
77#ifdef PROF
78# define USEPV_PROF std
79#else
80# define USEPV_PROF no
81#endif
82
83#if RTLD_PRIVATE_ERRNO
84# define SYSCALL_ERROR_LABEL $syscall_error
85# define SYSCALL_ERROR_HANDLER \
86$syscall_error: \
87 stl v0, rtld_errno(gp) !gprel; \
88 lda v0, -1; \
89 ret
90# define SYSCALL_ERROR_FALLTHRU
91#elif defined(PIC)
92# define SYSCALL_ERROR_LABEL __syscall_error !samegp
93# define SYSCALL_ERROR_HANDLER
94# define SYSCALL_ERROR_FALLTHRU br SYSCALL_ERROR_LABEL
95#else
96# define SYSCALL_ERROR_LABEL $syscall_error
97# define SYSCALL_ERROR_HANDLER \
98$syscall_error: \
99 jmp $31, __syscall_error
100# define SYSCALL_ERROR_FALLTHRU
101#endif /* RTLD_PRIVATE_ERRNO */
102
103/* Overridden by specific syscalls. */
104#undef PSEUDO_PREPARE_ARGS
105#define PSEUDO_PREPARE_ARGS /* Nothing. */
106
107#define PSEUDO(name, syscall_name, args) \
108 .globl name; \
109 .align 4; \
110 .ent name,0; \
111__LABEL(name) \
112 PSEUDO_PROLOGUE; \
113 PSEUDO_PREPARE_ARGS \
114 lda v0, SYS_ify(syscall_name); \
115 call_pal PAL_callsys; \
116 bne a3, SYSCALL_ERROR_LABEL
117
118#undef PSEUDO_END
119#define PSEUDO_END(sym) \
120 SYSCALL_ERROR_HANDLER; \
121 END(sym)
122
123#define PSEUDO_NOERRNO(name, syscall_name, args) \
124 .globl name; \
125 .align 4; \
126 .ent name,0; \
127__LABEL(name) \
128 PSEUDO_PROLOGUE; \
129 PSEUDO_PREPARE_ARGS \
130 lda v0, SYS_ify(syscall_name); \
131 call_pal PAL_callsys;
132
133#undef PSEUDO_END_NOERRNO
134#define PSEUDO_END_NOERRNO(sym) END(sym)
135
136#define ret_NOERRNO ret
137
138#define PSEUDO_ERRVAL(name, syscall_name, args) \
139 .globl name; \
140 .align 4; \
141 .ent name,0; \
142__LABEL(name) \
143 PSEUDO_PROLOGUE; \
144 PSEUDO_PREPARE_ARGS \
145 lda v0, SYS_ify(syscall_name); \
146 call_pal PAL_callsys;
147
148#undef PSEUDO_END_ERRVAL
149#define PSEUDO_END_ERRVAL(sym) END(sym)
150
151#define ret_ERRVAL ret
152
153#define r0 v0
154#define r1 a4
155
156#define MOVE(x,y) mov x,y
157
158#else /* !ASSEMBLER */
159
160/* In order to get __set_errno() definition in INLINE_SYSCALL. */
161#include <errno.h>
162
163/* ??? Linux needs to be able to override INLINE_SYSCALL for one
164 particular special case. Make this easy. */
165
166#undef INLINE_SYSCALL
167#define INLINE_SYSCALL(name, nr, args...) \
168 INLINE_SYSCALL1(name, nr, args)
169
170#define INLINE_SYSCALL1(name, nr, args...) \
171({ \
172 long _sc_ret, _sc_err; \
173 inline_syscall##nr(__NR_##name, args); \
174 if (__builtin_expect (_sc_err, 0)) \
175 { \
176 __set_errno (_sc_ret); \
177 _sc_ret = -1L; \
178 } \
179 _sc_ret; \
180})
181
182#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
183 INTERNAL_SYSCALL1(name, err_out, nr, args)
184
185#define INTERNAL_SYSCALL1(name, err_out, nr, args...) \
186 INTERNAL_SYSCALL_NCS(__NR_##name, err_out, nr, args)
187
188#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
189({ \
190 long _sc_ret, _sc_err; \
191 inline_syscall##nr(name, args); \
192 err_out = _sc_err; \
193 _sc_ret; \
194})
195
196#define INTERNAL_SYSCALL_DECL(err) \
197 long int err __attribute__((unused))
198
199/* The normal Alpha calling convention sign-extends 32-bit quantties
200 no matter what the "real" sign of the 32-bit type. We want to
201 preserve that when filling in values for the kernel. */
202#define syscall_promote(arg) \
203 (sizeof(arg) == 4 ? (long)(int)(long)(arg) : (long)(arg))
204
205/* Make sure and "use" the variable that we're not returning,
206 in order to suppress unused variable warnings. */
207#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void)val, err)
208#define INTERNAL_SYSCALL_ERRNO(val, err) ((void)err, val)
209
210#define inline_syscall_clobbers \
211 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
212 "$22", "$23", "$24", "$25", "$27", "$28", "memory"
213
214/* It is moderately important optimization-wise to limit the lifetime
215 of the hard-register variables as much as possible. Thus we copy
216 in/out as close to the asm as possible. */
217
218#define inline_syscall0(name, args...) \
219{ \
220 register long _sc_19 __asm__("$19"); \
221 register long _sc_0 = name; \
222 __asm__ __volatile__ \
223 ("callsys # %0 %1 <= %2" \
224 : "+v"(_sc_0), "=r"(_sc_19) \
225 : : inline_syscall_clobbers, \
226 "$16", "$17", "$18", "$20", "$21"); \
227 _sc_ret = _sc_0, _sc_err = _sc_19; \
228}
229
230#define inline_syscall1(name,arg1) \
231{ \
232 register long _tmp_16 = syscall_promote (arg1); \
233 register long _sc_0 = name; \
234 register long _sc_16 __asm__("$16") = _tmp_16; \
235 register long _sc_19 __asm__("$19"); \
236 __asm__ __volatile__ \
237 ("callsys # %0 %1 <= %2 %3" \
238 : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16) \
239 : : inline_syscall_clobbers, \
240 "$17", "$18", "$20", "$21"); \
241 _sc_ret = _sc_0, _sc_err = _sc_19; \
242}
243
244#define inline_syscall2(name,arg1,arg2) \
245{ \
246 register long _tmp_16 = syscall_promote (arg1); \
247 register long _tmp_17 = syscall_promote (arg2); \
248 register long _sc_0 = name; \
249 register long _sc_16 __asm__("$16") = _tmp_16; \
250 register long _sc_17 __asm__("$17") = _tmp_17; \
251 register long _sc_19 __asm__("$19"); \
252 __asm__ __volatile__ \
253 ("callsys # %0 %1 <= %2 %3 %4" \
254 : "+v"(_sc_0), "=r"(_sc_19), \
255 "+r"(_sc_16), "+r"(_sc_17) \
256 : : inline_syscall_clobbers, \
257 "$18", "$20", "$21"); \
258 _sc_ret = _sc_0, _sc_err = _sc_19; \
259}
260
261#define inline_syscall3(name,arg1,arg2,arg3) \
262{ \
263 register long _tmp_16 = syscall_promote (arg1); \
264 register long _tmp_17 = syscall_promote (arg2); \
265 register long _tmp_18 = syscall_promote (arg3); \
266 register long _sc_0 = name; \
267 register long _sc_16 __asm__("$16") = _tmp_16; \
268 register long _sc_17 __asm__("$17") = _tmp_17; \
269 register long _sc_18 __asm__("$18") = _tmp_18; \
270 register long _sc_19 __asm__("$19"); \
271 __asm__ __volatile__ \
272 ("callsys # %0 %1 <= %2 %3 %4 %5" \
273 : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16), \
274 "+r"(_sc_17), "+r"(_sc_18) \
275 : : inline_syscall_clobbers, "$20", "$21"); \
276 _sc_ret = _sc_0, _sc_err = _sc_19; \
277}
278
279#define inline_syscall4(name,arg1,arg2,arg3,arg4) \
280{ \
281 register long _tmp_16 = syscall_promote (arg1); \
282 register long _tmp_17 = syscall_promote (arg2); \
283 register long _tmp_18 = syscall_promote (arg3); \
284 register long _tmp_19 = syscall_promote (arg4); \
285 register long _sc_0 = name; \
286 register long _sc_16 __asm__("$16") = _tmp_16; \
287 register long _sc_17 __asm__("$17") = _tmp_17; \
288 register long _sc_18 __asm__("$18") = _tmp_18; \
289 register long _sc_19 __asm__("$19") = _tmp_19; \
290 __asm__ __volatile__ \
291 ("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
292 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
293 "+r"(_sc_17), "+r"(_sc_18) \
294 : : inline_syscall_clobbers, "$20", "$21"); \
295 _sc_ret = _sc_0, _sc_err = _sc_19; \
296}
297
298#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
299{ \
300 register long _tmp_16 = syscall_promote (arg1); \
301 register long _tmp_17 = syscall_promote (arg2); \
302 register long _tmp_18 = syscall_promote (arg3); \
303 register long _tmp_19 = syscall_promote (arg4); \
304 register long _tmp_20 = syscall_promote (arg5); \
305 register long _sc_0 = name; \
306 register long _sc_16 __asm__("$16") = _tmp_16; \
307 register long _sc_17 __asm__("$17") = _tmp_17; \
308 register long _sc_18 __asm__("$18") = _tmp_18; \
309 register long _sc_19 __asm__("$19") = _tmp_19; \
310 register long _sc_20 __asm__("$20") = _tmp_20; \
311 __asm__ __volatile__ \
312 ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
313 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
314 "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20) \
315 : : inline_syscall_clobbers, "$21"); \
316 _sc_ret = _sc_0, _sc_err = _sc_19; \
317}
318
319#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
320{ \
321 register long _tmp_16 = syscall_promote (arg1); \
322 register long _tmp_17 = syscall_promote (arg2); \
323 register long _tmp_18 = syscall_promote (arg3); \
324 register long _tmp_19 = syscall_promote (arg4); \
325 register long _tmp_20 = syscall_promote (arg5); \
326 register long _tmp_21 = syscall_promote (arg6); \
327 register long _sc_0 = name; \
328 register long _sc_16 __asm__("$16") = _tmp_16; \
329 register long _sc_17 __asm__("$17") = _tmp_17; \
330 register long _sc_18 __asm__("$18") = _tmp_18; \
331 register long _sc_19 __asm__("$19") = _tmp_19; \
332 register long _sc_20 __asm__("$20") = _tmp_20; \
333 register long _sc_21 __asm__("$21") = _tmp_21; \
334 __asm__ __volatile__ \
335 ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
336 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
337 "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20), \
338 "+r"(_sc_21) \
339 : : inline_syscall_clobbers); \
340 _sc_ret = _sc_0, _sc_err = _sc_19; \
341}
342#endif /* ASSEMBLER */
343
344/* Pointer mangling support. Note that tls access is slow enough that
345 we don't deoptimize things by placing the pointer check value there. */
346
347#ifdef __ASSEMBLER__
348# if IS_IN (rtld)
349# define PTR_MANGLE(dst, src, tmp) \
350 ldah tmp, __pointer_chk_guard_local($29) !gprelhigh; \
351 ldq tmp, __pointer_chk_guard_local(tmp) !gprellow; \
352 xor src, tmp, dst
353# define PTR_MANGLE2(dst, src, tmp) \
354 xor src, tmp, dst
355# elif defined SHARED
356# define PTR_MANGLE(dst, src, tmp) \
357 ldq tmp, __pointer_chk_guard; \
358 xor src, tmp, dst
359# else
360# define PTR_MANGLE(dst, src, tmp) \
361 ldq tmp, __pointer_chk_guard_local; \
362 xor src, tmp, dst
363# endif
364# define PTR_MANGLE2(dst, src, tmp) \
365 xor src, tmp, dst
366# define PTR_DEMANGLE(dst, tmp) PTR_MANGLE(dst, dst, tmp)
367# define PTR_DEMANGLE2(dst, tmp) PTR_MANGLE2(dst, dst, tmp)
368#else
369# include <stdint.h>
370# if (IS_IN (rtld) \
371 || (!defined SHARED && (IS_IN (libc) \
372 || IS_IN (libpthread))))
373extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
374# define PTR_MANGLE(var) \
375 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
376# else
377extern uintptr_t __pointer_chk_guard attribute_relro;
378# define PTR_MANGLE(var) \
379 (var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
380# endif
381# define PTR_DEMANGLE(var) PTR_MANGLE(var)
382#endif /* ASSEMBLER */
libc/glibc/sysdeps/unix/arm/sysdep.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <sysdeps/unix/sysdep.h>
19#include <sysdeps/arm/sysdep.h>
20
21/* Some definitions to allow the assembler in sysdeps/unix/ to build
22 without needing ARM-specific versions of all the files. */
23
24#ifdef __ASSEMBLER__
25
26#define ret DO_RET (r14)
27#define MOVE(a,b) mov b,a
28
29#endif
libc/glibc/sysdeps/unix/i386/sysdep.h created+35
...@@ -0,0 +1,35 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <sysdeps/unix/sysdep.h>
19#include <sysdeps/i386/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* This is defined as a separate macro so that other sysdep.h files
24 can include this one and then redefine DO_CALL. */
25
26#define DO_CALL(syscall_name, args) \
27 lea SYS_ify (syscall_name), %eax; \
28 lcall $7, $0
29
30#define r0 %eax /* Normal return-value register. */
31#define r1 %edx /* Secondary return-value register. */
32#define scratch %ecx /* Call-clobbered register for random use. */
33#define MOVE(x,y) movl x, y
34
35#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/unix/mips/mips32/sysdep.h created+56
...@@ -0,0 +1,56 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Brendan Kehoe (brendan@zen.org).
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/mips/sysdep.h>
20
21/* Note that while it's better structurally, going back to call __syscall_error
22 can make things confusing if you're debugging---it looks like it's jumping
23 backwards into the previous fn. */
24#ifdef __PIC__
25#define PSEUDO(name, syscall_name, args) \
26 .align 2; \
27 .set nomips16; \
28 cfi_startproc; \
29 99: la t9,__syscall_error; \
30 jr t9; \
31 cfi_endproc; \
32 ENTRY(name) \
33 .set noreorder; \
34 .cpload t9; \
35 li v0, SYS_ify(syscall_name); \
36 syscall; \
37 .set reorder; \
38 bne a3, zero, 99b; \
39L(syse1):
40#else
41#define PSEUDO(name, syscall_name, args) \
42 .set noreorder; \
43 .set nomips16; \
44 .align 2; \
45 cfi_startproc; \
46 99: j __syscall_error; \
47 nop; \
48 cfi_endproc; \
49 ENTRY(name) \
50 .set noreorder; \
51 li v0, SYS_ify(syscall_name); \
52 syscall; \
53 .set reorder; \
54 bne a3, zero, 99b; \
55L(syse1):
56#endif
libc/glibc/sysdeps/unix/mips/mips64/n32/sysdep.h created+64
...@@ -0,0 +1,64 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/mips/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Note that while it's better structurally, going back to call __syscall_error
24 can make things confusing if you're debugging---it looks like it's jumping
25 backwards into the previous fn. */
26#ifdef __PIC__
27#define PSEUDO(name, syscall_name, args) \
28 .align 2; \
29 .set nomips16; \
30 cfi_startproc; \
31 99:; \
32 .set noat; \
33 .cpsetup t9, $1, name; \
34 cfi_register (gp, $1); \
35 .set at; \
36 la t9,__syscall_error; \
37 .cpreturn; \
38 cfi_restore (gp); \
39 jr t9; \
40 cfi_endproc; \
41 ENTRY(name) \
42 li v0, SYS_ify(syscall_name); \
43 syscall; \
44 bne a3, zero, 99b; \
45L(syse1):
46#else
47#define PSEUDO(name, syscall_name, args) \
48 .set noreorder; \
49 .align 2; \
50 .set nomips16; \
51 cfi_startproc; \
52 99: j __syscall_error; \
53 nop; \
54 cfi_endproc; \
55 ENTRY(name) \
56 .set noreorder; \
57 li v0, SYS_ify(syscall_name); \
58 syscall; \
59 .set reorder; \
60 bne a3, zero, 99b; \
61L(syse1):
62#endif
63
64#endif
libc/glibc/sysdeps/unix/mips/mips64/n64/sysdep.h created+64
...@@ -0,0 +1,64 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/mips/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Note that while it's better structurally, going back to call __syscall_error
24 can make things confusing if you're debugging---it looks like it's jumping
25 backwards into the previous fn. */
26#ifdef __PIC__
27#define PSEUDO(name, syscall_name, args) \
28 .align 2; \
29 .set nomips16; \
30 cfi_startproc; \
31 99:; \
32 .set noat; \
33 .cpsetup t9, $1, name; \
34 cfi_register (gp, $1); \
35 .set at; \
36 dla t9,__syscall_error; \
37 .cpreturn; \
38 cfi_restore (gp); \
39 jr t9; \
40 cfi_endproc; \
41 ENTRY(name) \
42 li v0, SYS_ify(syscall_name); \
43 syscall; \
44 bne a3, zero, 99b; \
45L(syse1):
46#else
47#define PSEUDO(name, syscall_name, args) \
48 .set noreorder; \
49 .align 2; \
50 .set nomips16; \
51 cfi_startproc; \
52 99: j __syscall_error; \
53 nop; \
54 cfi_endproc; \
55 ENTRY(name) \
56 .set noreorder; \
57 li v0, SYS_ify(syscall_name); \
58 syscall; \
59 .set reorder; \
60 bne a3, zero, 99b; \
61L(syse1):
62#endif
63
64#endif
libc/glibc/sysdeps/unix/mips/sysdep.h created+85
...@@ -0,0 +1,85 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Brendan Kehoe (brendan@zen.org).
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sgidefs.h>
20#include <sysdeps/unix/sysdep.h>
21
22#ifndef __mips_isa_rev
23# define __mips_isa_rev 0
24#endif
25
26#ifdef __ASSEMBLER__
27
28#include <regdef.h>
29
30#define ENTRY(name) \
31 .globl name; \
32 .align 2; \
33 .ent name,0; \
34 name##: \
35 cfi_startproc;
36
37#undef END
38#define END(function) \
39 cfi_endproc; \
40 .end function; \
41 .size function,.-function
42
43#define ret j ra ; nop
44
45#undef PSEUDO_END
46#define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
47
48#define PSEUDO_NOERRNO(name, syscall_name, args) \
49 .align 2; \
50 ENTRY(name) \
51 .set nomips16; \
52 .set noreorder; \
53 li v0, SYS_ify(syscall_name); \
54 syscall
55
56#undef PSEUDO_END_NOERRNO
57#define PSEUDO_END_NOERRNO(sym) cfi_endproc; .end sym; .size sym,.-sym
58
59#define ret_NOERRNO ret
60
61#define PSEUDO_ERRVAL(name, syscall_name, args) \
62 .align 2; \
63 ENTRY(name) \
64 .set nomips16; \
65 .set noreorder; \
66 li v0, SYS_ify(syscall_name); \
67 syscall
68
69#undef PSEUDO_END_ERRVAL
70#define PSEUDO_END_ERRVAL(sym) cfi_endproc; .end sym; .size sym,.-sym
71
72#define ret_ERRVAL ret
73
74#define r0 v0
75#define r1 v1
76/* The mips move insn is d,s. */
77#define MOVE(x,y) move y , x
78
79#if _MIPS_SIM == _ABIO32
80# define L(label) $L ## label
81#else
82# define L(label) .L ## label
83#endif
84
85#endif
libc/glibc/sysdeps/unix/powerpc/sysdep.h created+24
...@@ -0,0 +1,24 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <sysdeps/unix/sysdep.h>
19#include <bits/wordsize.h>
20#if __WORDSIZE == 64
21#include <sysdeps/powerpc/powerpc64/sysdep.h>
22#else
23#include <sysdeps/powerpc/powerpc32/sysdep.h>
24#endif
libc/glibc/sysdeps/unix/sh/sysdep.h created+28
...@@ -0,0 +1,28 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <sysdeps/unix/sysdep.h>
19#include <sysdeps/sh/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23#define ret rts ; nop
24
25/* The sh move insn is s, d. */
26#define MOVE(x,y) mov x , y
27
28#endif
libc/glibc/sysdeps/unix/sysdep.h created+148
...@@ -0,0 +1,148 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <sysdeps/generic/sysdep.h>
19
20#include <sys/syscall.h>
21#define HAVE_SYSCALLS
22
23/* Note that using a `PASTE' macro loses. */
24#define SYSCALL__(name, args) PSEUDO (__##name, name, args)
25#define SYSCALL(name, args) PSEUDO (name, name, args)
26
27#define __SYSCALL_CONCAT_X(a,b) a##b
28#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b)
29
30
31#define __INTERNAL_SYSCALL0(name, err) \
32 INTERNAL_SYSCALL (name, err, 0)
33#define __INTERNAL_SYSCALL1(name, err, a1) \
34 INTERNAL_SYSCALL (name, err, 1, a1)
35#define __INTERNAL_SYSCALL2(name, err, a1, a2) \
36 INTERNAL_SYSCALL (name, err, 2, a1, a2)
37#define __INTERNAL_SYSCALL3(name, err, a1, a2, a3) \
38 INTERNAL_SYSCALL (name, err, 3, a1, a2, a3)
39#define __INTERNAL_SYSCALL4(name, err, a1, a2, a3, a4) \
40 INTERNAL_SYSCALL (name, err, 4, a1, a2, a3, a4)
41#define __INTERNAL_SYSCALL5(name, err, a1, a2, a3, a4, a5) \
42 INTERNAL_SYSCALL (name, err, 5, a1, a2, a3, a4, a5)
43#define __INTERNAL_SYSCALL6(name, err, a1, a2, a3, a4, a5, a6) \
44 INTERNAL_SYSCALL (name, err, 6, a1, a2, a3, a4, a5, a6)
45#define __INTERNAL_SYSCALL7(name, err, a1, a2, a3, a4, a5, a6, a7) \
46 INTERNAL_SYSCALL (name, err, 7, a1, a2, a3, a4, a5, a6, a7)
47
48#define __INTERNAL_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,o,...) o
49#define __INTERNAL_SYSCALL_NARGS(...) \
50 __INTERNAL_SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
51#define __INTERNAL_SYSCALL_DISP(b,...) \
52 __SYSCALL_CONCAT (b,__INTERNAL_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
53
54/* Issue a syscall defined by syscall number plus any other argument required.
55 It is similar to INTERNAL_SYSCALL macro, but without the need to pass the
56 expected argument number as second parameter. */
57#define INTERNAL_SYSCALL_CALL(...) \
58 __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL, __VA_ARGS__)
59
60#define __INLINE_SYSCALL0(name) \
61 INLINE_SYSCALL (name, 0)
62#define __INLINE_SYSCALL1(name, a1) \
63 INLINE_SYSCALL (name, 1, a1)
64#define __INLINE_SYSCALL2(name, a1, a2) \
65 INLINE_SYSCALL (name, 2, a1, a2)
66#define __INLINE_SYSCALL3(name, a1, a2, a3) \
67 INLINE_SYSCALL (name, 3, a1, a2, a3)
68#define __INLINE_SYSCALL4(name, a1, a2, a3, a4) \
69 INLINE_SYSCALL (name, 4, a1, a2, a3, a4)
70#define __INLINE_SYSCALL5(name, a1, a2, a3, a4, a5) \
71 INLINE_SYSCALL (name, 5, a1, a2, a3, a4, a5)
72#define __INLINE_SYSCALL6(name, a1, a2, a3, a4, a5, a6) \
73 INLINE_SYSCALL (name, 6, a1, a2, a3, a4, a5, a6)
74#define __INLINE_SYSCALL7(name, a1, a2, a3, a4, a5, a6, a7) \
75 INLINE_SYSCALL (name, 7, a1, a2, a3, a4, a5, a6, a7)
76
77#define __INLINE_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
78#define __INLINE_SYSCALL_NARGS(...) \
79 __INLINE_SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
80#define __INLINE_SYSCALL_DISP(b,...) \
81 __SYSCALL_CONCAT (b,__INLINE_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
82
83/* Issue a syscall defined by syscall number plus any other argument
84 required. Any error will be handled using arch defined macros and errno
85 will be set accordingly.
86 It is similar to INLINE_SYSCALL macro, but without the need to pass the
87 expected argument number as second parameter. */
88#define INLINE_SYSCALL_CALL(...) \
89 __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__)
90
91#define SYSCALL_CANCEL(...) \
92 ({ \
93 long int sc_ret; \
94 if (SINGLE_THREAD_P) \
95 sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \
96 else \
97 { \
98 int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \
99 sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \
100 LIBC_CANCEL_RESET (sc_cancel_oldtype); \
101 } \
102 sc_ret; \
103 })
104
105/* Issue a syscall defined by syscall number plus any other argument
106 required. Any error will be returned unmodified (including errno). */
107#define INTERNAL_SYSCALL_CANCEL(...) \
108 ({ \
109 long int sc_ret; \
110 if (SINGLE_THREAD_P) \
111 sc_ret = INTERNAL_SYSCALL_CALL (__VA_ARGS__); \
112 else \
113 { \
114 int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \
115 sc_ret = INTERNAL_SYSCALL_CALL (__VA_ARGS__); \
116 LIBC_CANCEL_RESET (sc_cancel_oldtype); \
117 } \
118 sc_ret; \
119 })
120
121/* Machine-dependent sysdep.h files are expected to define the macro
122 PSEUDO (function_name, syscall_name) to emit assembly code to define the
123 C-callable function FUNCTION_NAME to do system call SYSCALL_NAME.
124 r0 and r1 are the system call outputs. MOVE(x, y) should be defined as
125 an instruction such that "MOVE(r1, r0)" works. ret should be defined
126 as the return instruction. */
127
128#ifndef SYS_ify
129#define SYS_ify(syscall_name) SYS_##syscall_name
130#endif
131
132/* Terminate a system call named SYM. This is used on some platforms
133 to generate correct debugging information. */
134#ifndef PSEUDO_END
135#define PSEUDO_END(sym)
136#endif
137#ifndef PSEUDO_END_NOERRNO
138#define PSEUDO_END_NOERRNO(sym) PSEUDO_END(sym)
139#endif
140#ifndef PSEUDO_END_ERRVAL
141#define PSEUDO_END_ERRVAL(sym) PSEUDO_END(sym)
142#endif
143
144/* Wrappers around system calls should normally inline the system call code.
145 But sometimes it is not possible or implemented and we use this code. */
146#ifndef INLINE_SYSCALL
147#define INLINE_SYSCALL(name, nr, args...) __syscall_##name (args)
148#endif
libc/glibc/sysdeps/unix/sysv/linux/aarch64/asm/unistd.h created+21
...@@ -0,0 +1,21 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * Copyright (C) 2012 ARM Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#define __ARCH_WANT_RENAMEAT
19#define __ARCH_WANT_NEW_STAT
20
21#include <asm-generic/unistd.h>
libc/glibc/sysdeps/unix/sysv/linux/aarch64/kernel-features.h created+23
...@@ -0,0 +1,23 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. AArch64 version.
3 Copyright (C) 2018-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include_next <kernel-features.h>
21
22#undef __ASSUME_CLONE_DEFAULT
23#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/aarch64/sys/elf.h created+26
...@@ -0,0 +1,26 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_ELF_H
20#define _SYS_ELF_H 1
21
22#warning "This header is obsolete; use <sys/procfs.h> instead."
23
24#include <sys/procfs.h>
25
26#endif /* sys/elf.h */
libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h created+302
...@@ -0,0 +1,302 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_AARCH64_SYSDEP_H
20#define _LINUX_AARCH64_SYSDEP_H 1
21
22/* Always enable vsyscalls on aarch64 */
23#define ALWAYS_USE_VSYSCALL 1
24
25#include <sysdeps/unix/sysdep.h>
26#include <sysdeps/aarch64/sysdep.h>
27#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
28
29/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
30#include <dl-sysdep.h>
31
32#include <tls.h>
33
34/* In order to get __set_errno() definition in INLINE_SYSCALL. */
35#ifndef __ASSEMBLER__
36#include <errno.h>
37#endif
38
39/* For Linux we can use the system call table in the header file
40 /usr/include/asm/unistd.h
41 of the kernel. But these symbols do not follow the SYS_* syntax
42 so we have to redefine the `SYS_ify' macro here. */
43#undef SYS_ify
44#define SYS_ify(syscall_name) (__NR_##syscall_name)
45
46#ifdef __ASSEMBLER__
47
48/* Linux uses a negative return value to indicate syscall errors,
49 unlike most Unices, which use the condition codes' carry flag.
50
51 Since version 2.1 the return value of a system call might be
52 negative even if the call succeeded. E.g., the `lseek' system call
53 might return a large offset. Therefore we must not anymore test
54 for < 0, but test for a real error by making sure the value in R0
55 is a real error number. Linus said he will make sure the no syscall
56 returns a value in -1 .. -4095 as a valid result so we can safely
57 test with -4095. */
58
59# undef PSEUDO
60# define PSEUDO(name, syscall_name, args) \
61 .text; \
62 ENTRY (name); \
63 DO_CALL (syscall_name, args); \
64 cmn x0, #4095; \
65 b.cs .Lsyscall_error;
66
67# undef PSEUDO_END
68# define PSEUDO_END(name) \
69 SYSCALL_ERROR_HANDLER \
70 END (name)
71
72# undef PSEUDO_NOERRNO
73# define PSEUDO_NOERRNO(name, syscall_name, args) \
74 .text; \
75 ENTRY (name); \
76 DO_CALL (syscall_name, args);
77
78# undef PSEUDO_END_NOERRNO
79# define PSEUDO_END_NOERRNO(name) \
80 END (name)
81
82# define ret_NOERRNO ret
83
84/* The function has to return the error code. */
85# undef PSEUDO_ERRVAL
86# define PSEUDO_ERRVAL(name, syscall_name, args) \
87 .text; \
88 ENTRY (name) \
89 DO_CALL (syscall_name, args); \
90 neg x0, x0
91
92# undef PSEUDO_END_ERRVAL
93# define PSEUDO_END_ERRVAL(name) \
94 END (name)
95
96# define ret_ERRVAL ret
97
98# if !IS_IN (libc)
99# define SYSCALL_ERROR .Lsyscall_error
100# if RTLD_PRIVATE_ERRNO
101# define SYSCALL_ERROR_HANDLER \
102.Lsyscall_error: \
103 adrp x1, C_SYMBOL_NAME(rtld_errno); \
104 neg w0, w0; \
105 str w0, [x1, :lo12:C_SYMBOL_NAME(rtld_errno)]; \
106 mov x0, -1; \
107 RET;
108# else
109
110# define SYSCALL_ERROR_HANDLER \
111.Lsyscall_error: \
112 adrp x1, :gottprel:errno; \
113 neg w2, w0; \
114 ldr PTR_REG(1), [x1, :gottprel_lo12:errno]; \
115 mrs x3, tpidr_el0; \
116 mov x0, -1; \
117 str w2, [x1, x3]; \
118 RET;
119# endif
120# else
121# define SYSCALL_ERROR __syscall_error
122# define SYSCALL_ERROR_HANDLER \
123.Lsyscall_error: \
124 b __syscall_error;
125# endif
126
127/* Linux takes system call args in registers:
128 syscall number x8
129 arg 1 x0
130 arg 2 x1
131 arg 3 x2
132 arg 4 x3
133 arg 5 x4
134 arg 6 x5
135 arg 7 x6
136
137 The compiler is going to form a call by coming here, through PSEUDO, with
138 arguments
139 syscall number in the DO_CALL macro
140 arg 1 x0
141 arg 2 x1
142 arg 3 x2
143 arg 4 x3
144 arg 5 x4
145 arg 6 x5
146 arg 7 x6
147
148*/
149
150# undef DO_CALL
151# define DO_CALL(syscall_name, args) \
152 mov x8, SYS_ify (syscall_name); \
153 svc 0
154
155#else /* not __ASSEMBLER__ */
156
157
158/* List of system calls which are supported as vsyscalls. */
159# define HAVE_CLOCK_GETRES_VSYSCALL 1
160# define HAVE_CLOCK_GETTIME_VSYSCALL 1
161# define HAVE_GETTIMEOFDAY_VSYSCALL 1
162
163/* Previously AArch64 used the generic version without the libc_hidden_def
164 which lead in a non existent __send symbol in libc.so. */
165# undef HAVE_INTERNAL_SEND_SYMBOL
166
167# define SINGLE_THREAD_BY_GLOBAL 1
168
169/* Define a macro which expands into the inline wrapper code for a system
170 call. */
171# undef INLINE_SYSCALL
172# define INLINE_SYSCALL(name, nr, args...) \
173 ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
174 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
175 { \
176 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
177 _sys_result = (unsigned long) -1; \
178 } \
179 (long) _sys_result; })
180
181# undef INTERNAL_SYSCALL_DECL
182# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
183
184# undef INTERNAL_SYSCALL_RAW
185# define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
186 ({ long _sys_result; \
187 { \
188 LOAD_ARGS_##nr (args) \
189 register long _x8 asm ("x8") = (name); \
190 asm volatile ("svc 0 // syscall " # name \
191 : "=r" (_x0) : "r"(_x8) ASM_ARGS_##nr : "memory"); \
192 _sys_result = _x0; \
193 } \
194 _sys_result; })
195
196# undef INTERNAL_SYSCALL
197# define INTERNAL_SYSCALL(name, err, nr, args...) \
198 INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
199
200# undef INTERNAL_SYSCALL_AARCH64
201# define INTERNAL_SYSCALL_AARCH64(name, err, nr, args...) \
202 INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
203
204# undef INTERNAL_SYSCALL_ERROR_P
205# define INTERNAL_SYSCALL_ERROR_P(val, err) \
206 ((unsigned long) (val) >= (unsigned long) -4095)
207
208# undef INTERNAL_SYSCALL_ERRNO
209# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
210
211# define LOAD_ARGS_0() \
212 register long _x0 asm ("x0");
213# define LOAD_ARGS_1(x0) \
214 long _x0tmp = (long) (x0); \
215 LOAD_ARGS_0 () \
216 _x0 = _x0tmp;
217# define LOAD_ARGS_2(x0, x1) \
218 long _x1tmp = (long) (x1); \
219 LOAD_ARGS_1 (x0) \
220 register long _x1 asm ("x1") = _x1tmp;
221# define LOAD_ARGS_3(x0, x1, x2) \
222 long _x2tmp = (long) (x2); \
223 LOAD_ARGS_2 (x0, x1) \
224 register long _x2 asm ("x2") = _x2tmp;
225# define LOAD_ARGS_4(x0, x1, x2, x3) \
226 long _x3tmp = (long) (x3); \
227 LOAD_ARGS_3 (x0, x1, x2) \
228 register long _x3 asm ("x3") = _x3tmp;
229# define LOAD_ARGS_5(x0, x1, x2, x3, x4) \
230 long _x4tmp = (long) (x4); \
231 LOAD_ARGS_4 (x0, x1, x2, x3) \
232 register long _x4 asm ("x4") = _x4tmp;
233# define LOAD_ARGS_6(x0, x1, x2, x3, x4, x5) \
234 long _x5tmp = (long) (x5); \
235 LOAD_ARGS_5 (x0, x1, x2, x3, x4) \
236 register long _x5 asm ("x5") = _x5tmp;
237# define LOAD_ARGS_7(x0, x1, x2, x3, x4, x5, x6)\
238 long _x6tmp = (long) (x6); \
239 LOAD_ARGS_6 (x0, x1, x2, x3, x4, x5) \
240 register long _x6 asm ("x6") = _x6tmp;
241
242# define ASM_ARGS_0
243# define ASM_ARGS_1 , "r" (_x0)
244# define ASM_ARGS_2 ASM_ARGS_1, "r" (_x1)
245# define ASM_ARGS_3 ASM_ARGS_2, "r" (_x2)
246# define ASM_ARGS_4 ASM_ARGS_3, "r" (_x3)
247# define ASM_ARGS_5 ASM_ARGS_4, "r" (_x4)
248# define ASM_ARGS_6 ASM_ARGS_5, "r" (_x5)
249# define ASM_ARGS_7 ASM_ARGS_6, "r" (_x6)
250
251# undef INTERNAL_SYSCALL_NCS
252# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
253 INTERNAL_SYSCALL_RAW (number, err, nr, args)
254
255#endif /* __ASSEMBLER__ */
256
257/* Pointer mangling is supported for AArch64. */
258#if (IS_IN (rtld) || \
259 (!defined SHARED && (IS_IN (libc) \
260 || IS_IN (libpthread))))
261# ifdef __ASSEMBLER__
262/* Note, dst, src, guard, and tmp are all register numbers rather than
263 register names so they will work with both ILP32 and LP64. */
264# define PTR_MANGLE(dst, src, guard, tmp) \
265 LDST_PCREL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \
266 PTR_MANGLE2 (dst, src, guard)
267/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
268# define PTR_MANGLE2(dst, src, guard)\
269 eor x##dst, x##src, x##guard
270# define PTR_DEMANGLE(dst, src, guard, tmp)\
271 PTR_MANGLE (dst, src, guard, tmp)
272# define PTR_DEMANGLE2(dst, src, guard)\
273 PTR_MANGLE2 (dst, src, guard)
274# else
275extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
276# define PTR_MANGLE(var) \
277 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
278# define PTR_DEMANGLE(var) PTR_MANGLE (var)
279# endif
280#else
281# ifdef __ASSEMBLER__
282/* Note, dst, src, guard, and tmp are all register numbers rather than
283 register names so they will work with both ILP32 and LP64. */
284# define PTR_MANGLE(dst, src, guard, tmp) \
285 LDST_GLOBAL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); \
286 PTR_MANGLE2 (dst, src, guard)
287/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
288# define PTR_MANGLE2(dst, src, guard)\
289 eor x##dst, x##src, x##guard
290# define PTR_DEMANGLE(dst, src, guard, tmp)\
291 PTR_MANGLE (dst, src, guard, tmp)
292# define PTR_DEMANGLE2(dst, src, guard)\
293 PTR_MANGLE2 (dst, src, guard)
294# else
295extern uintptr_t __pointer_chk_guard attribute_relro;
296# define PTR_MANGLE(var) \
297 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
298# define PTR_DEMANGLE(var) PTR_MANGLE (var)
299# endif
300#endif
301
302#endif /* linux/aarch64/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/alpha/asm/unistd.h created+489
...@@ -0,0 +1,489 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef _UAPI_ALPHA_UNISTD_H
3#define _UAPI_ALPHA_UNISTD_H
4
5#define __NR_osf_syscall 0 /* not implemented */
6#define __NR_exit 1
7#define __NR_fork 2
8#define __NR_read 3
9#define __NR_write 4
10#define __NR_osf_old_open 5 /* not implemented */
11#define __NR_close 6
12#define __NR_osf_wait4 7
13#define __NR_osf_old_creat 8 /* not implemented */
14#define __NR_link 9
15#define __NR_unlink 10
16#define __NR_osf_execve 11 /* not implemented */
17#define __NR_chdir 12
18#define __NR_fchdir 13
19#define __NR_mknod 14
20#define __NR_chmod 15
21#define __NR_chown 16
22#define __NR_brk 17
23#define __NR_osf_getfsstat 18 /* not implemented */
24#define __NR_lseek 19
25#define __NR_getxpid 20
26#define __NR_osf_mount 21
27#define __NR_umount 22
28#define __NR_setuid 23
29#define __NR_getxuid 24
30#define __NR_exec_with_loader 25 /* not implemented */
31#define __NR_ptrace 26
32#define __NR_osf_nrecvmsg 27 /* not implemented */
33#define __NR_osf_nsendmsg 28 /* not implemented */
34#define __NR_osf_nrecvfrom 29 /* not implemented */
35#define __NR_osf_naccept 30 /* not implemented */
36#define __NR_osf_ngetpeername 31 /* not implemented */
37#define __NR_osf_ngetsockname 32 /* not implemented */
38#define __NR_access 33
39#define __NR_osf_chflags 34 /* not implemented */
40#define __NR_osf_fchflags 35 /* not implemented */
41#define __NR_sync 36
42#define __NR_kill 37
43#define __NR_osf_old_stat 38 /* not implemented */
44#define __NR_setpgid 39
45#define __NR_osf_old_lstat 40 /* not implemented */
46#define __NR_dup 41
47#define __NR_pipe 42
48#define __NR_osf_set_program_attributes 43
49#define __NR_osf_profil 44 /* not implemented */
50#define __NR_open 45
51#define __NR_osf_old_sigaction 46 /* not implemented */
52#define __NR_getxgid 47
53#define __NR_osf_sigprocmask 48
54#define __NR_osf_getlogin 49 /* not implemented */
55#define __NR_osf_setlogin 50 /* not implemented */
56#define __NR_acct 51
57#define __NR_sigpending 52
58
59#define __NR_ioctl 54
60#define __NR_osf_reboot 55 /* not implemented */
61#define __NR_osf_revoke 56 /* not implemented */
62#define __NR_symlink 57
63#define __NR_readlink 58
64#define __NR_execve 59
65#define __NR_umask 60
66#define __NR_chroot 61
67#define __NR_osf_old_fstat 62 /* not implemented */
68#define __NR_getpgrp 63
69#define __NR_getpagesize 64
70#define __NR_osf_mremap 65 /* not implemented */
71#define __NR_vfork 66
72#define __NR_stat 67
73#define __NR_lstat 68
74#define __NR_osf_sbrk 69 /* not implemented */
75#define __NR_osf_sstk 70 /* not implemented */
76#define __NR_mmap 71 /* OSF/1 mmap is superset of Linux */
77#define __NR_osf_old_vadvise 72 /* not implemented */
78#define __NR_munmap 73
79#define __NR_mprotect 74
80#define __NR_madvise 75
81#define __NR_vhangup 76
82#define __NR_osf_kmodcall 77 /* not implemented */
83#define __NR_osf_mincore 78 /* not implemented */
84#define __NR_getgroups 79
85#define __NR_setgroups 80
86#define __NR_osf_old_getpgrp 81 /* not implemented */
87#define __NR_setpgrp 82 /* BSD alias for setpgid */
88#define __NR_osf_setitimer 83
89#define __NR_osf_old_wait 84 /* not implemented */
90#define __NR_osf_table 85 /* not implemented */
91#define __NR_osf_getitimer 86
92#define __NR_gethostname 87
93#define __NR_sethostname 88
94#define __NR_getdtablesize 89
95#define __NR_dup2 90
96#define __NR_fstat 91
97#define __NR_fcntl 92
98#define __NR_osf_select 93
99#define __NR_poll 94
100#define __NR_fsync 95
101#define __NR_setpriority 96
102#define __NR_socket 97
103#define __NR_connect 98
104#define __NR_accept 99
105#define __NR_getpriority 100
106#define __NR_send 101
107#define __NR_recv 102
108#define __NR_sigreturn 103
109#define __NR_bind 104
110#define __NR_setsockopt 105
111#define __NR_listen 106
112#define __NR_osf_plock 107 /* not implemented */
113#define __NR_osf_old_sigvec 108 /* not implemented */
114#define __NR_osf_old_sigblock 109 /* not implemented */
115#define __NR_osf_old_sigsetmask 110 /* not implemented */
116#define __NR_sigsuspend 111
117#define __NR_osf_sigstack 112
118#define __NR_recvmsg 113
119#define __NR_sendmsg 114
120#define __NR_osf_old_vtrace 115 /* not implemented */
121#define __NR_osf_gettimeofday 116
122#define __NR_osf_getrusage 117
123#define __NR_getsockopt 118
124
125#define __NR_readv 120
126#define __NR_writev 121
127#define __NR_osf_settimeofday 122
128#define __NR_fchown 123
129#define __NR_fchmod 124
130#define __NR_recvfrom 125
131#define __NR_setreuid 126
132#define __NR_setregid 127
133#define __NR_rename 128
134#define __NR_truncate 129
135#define __NR_ftruncate 130
136#define __NR_flock 131
137#define __NR_setgid 132
138#define __NR_sendto 133
139#define __NR_shutdown 134
140#define __NR_socketpair 135
141#define __NR_mkdir 136
142#define __NR_rmdir 137
143#define __NR_osf_utimes 138
144#define __NR_osf_old_sigreturn 139 /* not implemented */
145#define __NR_osf_adjtime 140 /* not implemented */
146#define __NR_getpeername 141
147#define __NR_osf_gethostid 142 /* not implemented */
148#define __NR_osf_sethostid 143 /* not implemented */
149#define __NR_getrlimit 144
150#define __NR_setrlimit 145
151#define __NR_osf_old_killpg 146 /* not implemented */
152#define __NR_setsid 147
153#define __NR_quotactl 148
154#define __NR_osf_oldquota 149 /* not implemented */
155#define __NR_getsockname 150
156
157#define __NR_osf_pid_block 153 /* not implemented */
158#define __NR_osf_pid_unblock 154 /* not implemented */
159
160#define __NR_sigaction 156
161#define __NR_osf_sigwaitprim 157 /* not implemented */
162#define __NR_osf_nfssvc 158 /* not implemented */
163#define __NR_osf_getdirentries 159
164#define __NR_osf_statfs 160
165#define __NR_osf_fstatfs 161
166
167#define __NR_osf_asynch_daemon 163 /* not implemented */
168#define __NR_osf_getfh 164 /* not implemented */
169#define __NR_osf_getdomainname 165
170#define __NR_setdomainname 166
171
172#define __NR_osf_exportfs 169 /* not implemented */
173
174#define __NR_osf_alt_plock 181 /* not implemented */
175
176#define __NR_osf_getmnt 184 /* not implemented */
177
178#define __NR_osf_alt_sigpending 187 /* not implemented */
179#define __NR_osf_alt_setsid 188 /* not implemented */
180
181#define __NR_osf_swapon 199
182#define __NR_msgctl 200
183#define __NR_msgget 201
184#define __NR_msgrcv 202
185#define __NR_msgsnd 203
186#define __NR_semctl 204
187#define __NR_semget 205
188#define __NR_semop 206
189#define __NR_osf_utsname 207
190#define __NR_lchown 208
191#define __NR_osf_shmat 209
192#define __NR_shmctl 210
193#define __NR_shmdt 211
194#define __NR_shmget 212
195#define __NR_osf_mvalid 213 /* not implemented */
196#define __NR_osf_getaddressconf 214 /* not implemented */
197#define __NR_osf_msleep 215 /* not implemented */
198#define __NR_osf_mwakeup 216 /* not implemented */
199#define __NR_msync 217
200#define __NR_osf_signal 218 /* not implemented */
201#define __NR_osf_utc_gettime 219 /* not implemented */
202#define __NR_osf_utc_adjtime 220 /* not implemented */
203
204#define __NR_osf_security 222 /* not implemented */
205#define __NR_osf_kloadcall 223 /* not implemented */
206
207#define __NR_osf_stat 224
208#define __NR_osf_lstat 225
209#define __NR_osf_fstat 226
210#define __NR_osf_statfs64 227
211#define __NR_osf_fstatfs64 228
212
213#define __NR_getpgid 233
214#define __NR_getsid 234
215#define __NR_sigaltstack 235
216#define __NR_osf_waitid 236 /* not implemented */
217#define __NR_osf_priocntlset 237 /* not implemented */
218#define __NR_osf_sigsendset 238 /* not implemented */
219#define __NR_osf_set_speculative 239 /* not implemented */
220#define __NR_osf_msfs_syscall 240 /* not implemented */
221#define __NR_osf_sysinfo 241
222#define __NR_osf_uadmin 242 /* not implemented */
223#define __NR_osf_fuser 243 /* not implemented */
224#define __NR_osf_proplist_syscall 244
225#define __NR_osf_ntp_adjtime 245 /* not implemented */
226#define __NR_osf_ntp_gettime 246 /* not implemented */
227#define __NR_osf_pathconf 247 /* not implemented */
228#define __NR_osf_fpathconf 248 /* not implemented */
229
230#define __NR_osf_uswitch 250 /* not implemented */
231#define __NR_osf_usleep_thread 251
232#define __NR_osf_audcntl 252 /* not implemented */
233#define __NR_osf_audgen 253 /* not implemented */
234#define __NR_sysfs 254
235#define __NR_osf_subsys_info 255 /* not implemented */
236#define __NR_osf_getsysinfo 256
237#define __NR_osf_setsysinfo 257
238#define __NR_osf_afs_syscall 258 /* not implemented */
239#define __NR_osf_swapctl 259 /* not implemented */
240#define __NR_osf_memcntl 260 /* not implemented */
241#define __NR_osf_fdatasync 261 /* not implemented */
242
243/*
244 * Ignore legacy syscalls that we don't use.
245 */
246#define __IGNORE_alarm
247#define __IGNORE_creat
248#define __IGNORE_getegid
249#define __IGNORE_geteuid
250#define __IGNORE_getgid
251#define __IGNORE_getpid
252#define __IGNORE_getppid
253#define __IGNORE_getuid
254#define __IGNORE_pause
255#define __IGNORE_time
256#define __IGNORE_utime
257#define __IGNORE_umount2
258
259/*
260 * Linux-specific system calls begin at 300
261 */
262#define __NR_bdflush 300
263#define __NR_sethae 301
264#define __NR_mount 302
265#define __NR_old_adjtimex 303
266#define __NR_swapoff 304
267#define __NR_getdents 305
268#define __NR_create_module 306
269#define __NR_init_module 307
270#define __NR_delete_module 308
271#define __NR_get_kernel_syms 309
272#define __NR_syslog 310
273#define __NR_reboot 311
274#define __NR_clone 312
275#define __NR_uselib 313
276#define __NR_mlock 314
277#define __NR_munlock 315
278#define __NR_mlockall 316
279#define __NR_munlockall 317
280#define __NR_sysinfo 318
281#define __NR__sysctl 319
282/* 320 was sys_idle. */
283#define __NR_oldumount 321
284#define __NR_swapon 322
285#define __NR_times 323
286#define __NR_personality 324
287#define __NR_setfsuid 325
288#define __NR_setfsgid 326
289#define __NR_ustat 327
290#define __NR_statfs 328
291#define __NR_fstatfs 329
292#define __NR_sched_setparam 330
293#define __NR_sched_getparam 331
294#define __NR_sched_setscheduler 332
295#define __NR_sched_getscheduler 333
296#define __NR_sched_yield 334
297#define __NR_sched_get_priority_max 335
298#define __NR_sched_get_priority_min 336
299#define __NR_sched_rr_get_interval 337
300#define __NR_afs_syscall 338
301#define __NR_uname 339
302#define __NR_nanosleep 340
303#define __NR_mremap 341
304#define __NR_nfsservctl 342
305#define __NR_setresuid 343
306#define __NR_getresuid 344
307#define __NR_pciconfig_read 345
308#define __NR_pciconfig_write 346
309#define __NR_query_module 347
310#define __NR_prctl 348
311#define __NR_pread64 349
312#define __NR_pwrite64 350
313#define __NR_rt_sigreturn 351
314#define __NR_rt_sigaction 352
315#define __NR_rt_sigprocmask 353
316#define __NR_rt_sigpending 354
317#define __NR_rt_sigtimedwait 355
318#define __NR_rt_sigqueueinfo 356
319#define __NR_rt_sigsuspend 357
320#define __NR_select 358
321#define __NR_gettimeofday 359
322#define __NR_settimeofday 360
323#define __NR_getitimer 361
324#define __NR_setitimer 362
325#define __NR_utimes 363
326#define __NR_getrusage 364
327#define __NR_wait4 365
328#define __NR_adjtimex 366
329#define __NR_getcwd 367
330#define __NR_capget 368
331#define __NR_capset 369
332#define __NR_sendfile 370
333#define __NR_setresgid 371
334#define __NR_getresgid 372
335#define __NR_dipc 373
336#define __NR_pivot_root 374
337#define __NR_mincore 375
338#define __NR_pciconfig_iobase 376
339#define __NR_getdents64 377
340#define __NR_gettid 378
341#define __NR_readahead 379
342/* 380 is unused */
343#define __NR_tkill 381
344#define __NR_setxattr 382
345#define __NR_lsetxattr 383
346#define __NR_fsetxattr 384
347#define __NR_getxattr 385
348#define __NR_lgetxattr 386
349#define __NR_fgetxattr 387
350#define __NR_listxattr 388
351#define __NR_llistxattr 389
352#define __NR_flistxattr 390
353#define __NR_removexattr 391
354#define __NR_lremovexattr 392
355#define __NR_fremovexattr 393
356#define __NR_futex 394
357#define __NR_sched_setaffinity 395
358#define __NR_sched_getaffinity 396
359#define __NR_tuxcall 397
360#define __NR_io_setup 398
361#define __NR_io_destroy 399
362#define __NR_io_getevents 400
363#define __NR_io_submit 401
364#define __NR_io_cancel 402
365#define __NR_exit_group 405
366#define __NR_lookup_dcookie 406
367#define __NR_epoll_create 407
368#define __NR_epoll_ctl 408
369#define __NR_epoll_wait 409
370#define __NR_remap_file_pages 410
371#define __NR_set_tid_address 411
372#define __NR_restart_syscall 412
373#define __NR_fadvise64 413
374#define __NR_timer_create 414
375#define __NR_timer_settime 415
376#define __NR_timer_gettime 416
377#define __NR_timer_getoverrun 417
378#define __NR_timer_delete 418
379#define __NR_clock_settime 419
380#define __NR_clock_gettime 420
381#define __NR_clock_getres 421
382#define __NR_clock_nanosleep 422
383#define __NR_semtimedop 423
384#define __NR_tgkill 424
385#define __NR_stat64 425
386#define __NR_lstat64 426
387#define __NR_fstat64 427
388#define __NR_vserver 428
389#define __NR_mbind 429
390#define __NR_get_mempolicy 430
391#define __NR_set_mempolicy 431
392#define __NR_mq_open 432
393#define __NR_mq_unlink 433
394#define __NR_mq_timedsend 434
395#define __NR_mq_timedreceive 435
396#define __NR_mq_notify 436
397#define __NR_mq_getsetattr 437
398#define __NR_waitid 438
399#define __NR_add_key 439
400#define __NR_request_key 440
401#define __NR_keyctl 441
402#define __NR_ioprio_set 442
403#define __NR_ioprio_get 443
404#define __NR_inotify_init 444
405#define __NR_inotify_add_watch 445
406#define __NR_inotify_rm_watch 446
407#define __NR_fdatasync 447
408#define __NR_kexec_load 448
409#define __NR_migrate_pages 449
410#define __NR_openat 450
411#define __NR_mkdirat 451
412#define __NR_mknodat 452
413#define __NR_fchownat 453
414#define __NR_futimesat 454
415#define __NR_fstatat64 455
416#define __NR_unlinkat 456
417#define __NR_renameat 457
418#define __NR_linkat 458
419#define __NR_symlinkat 459
420#define __NR_readlinkat 460
421#define __NR_fchmodat 461
422#define __NR_faccessat 462
423#define __NR_pselect6 463
424#define __NR_ppoll 464
425#define __NR_unshare 465
426#define __NR_set_robust_list 466
427#define __NR_get_robust_list 467
428#define __NR_splice 468
429#define __NR_sync_file_range 469
430#define __NR_tee 470
431#define __NR_vmsplice 471
432#define __NR_move_pages 472
433#define __NR_getcpu 473
434#define __NR_epoll_pwait 474
435#define __NR_utimensat 475
436#define __NR_signalfd 476
437#define __NR_timerfd 477
438#define __NR_eventfd 478
439#define __NR_recvmmsg 479
440#define __NR_fallocate 480
441#define __NR_timerfd_create 481
442#define __NR_timerfd_settime 482
443#define __NR_timerfd_gettime 483
444#define __NR_signalfd4 484
445#define __NR_eventfd2 485
446#define __NR_epoll_create1 486
447#define __NR_dup3 487
448#define __NR_pipe2 488
449#define __NR_inotify_init1 489
450#define __NR_preadv 490
451#define __NR_pwritev 491
452#define __NR_rt_tgsigqueueinfo 492
453#define __NR_perf_event_open 493
454#define __NR_fanotify_init 494
455#define __NR_fanotify_mark 495
456#define __NR_prlimit64 496
457#define __NR_name_to_handle_at 497
458#define __NR_open_by_handle_at 498
459#define __NR_clock_adjtime 499
460#define __NR_syncfs 500
461#define __NR_setns 501
462#define __NR_accept4 502
463#define __NR_sendmmsg 503
464#define __NR_process_vm_readv 504
465#define __NR_process_vm_writev 505
466#define __NR_kcmp 506
467#define __NR_finit_module 507
468#define __NR_sched_setattr 508
469#define __NR_sched_getattr 509
470#define __NR_renameat2 510
471#define __NR_getrandom 511
472#define __NR_memfd_create 512
473#define __NR_execveat 513
474#define __NR_seccomp 514
475#define __NR_bpf 515
476#define __NR_userfaultfd 516
477#define __NR_membarrier 517
478#define __NR_mlock2 518
479#define __NR_copy_file_range 519
480#define __NR_preadv2 520
481#define __NR_pwritev2 521
482#define __NR_statx 522
483
484/* Alpha doesn't have protection keys. */
485#define __IGNORE_pkey_mprotect
486#define __IGNORE_pkey_alloc
487#define __IGNORE_pkey_free
488
489#endif /* _UAPI_ALPHA_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/alpha/bits/stat.h created+160
...@@ -0,0 +1,160 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_KERNEL 0
27#define _STAT_VER_GLIBC2 1
28#define _STAT_VER_GLIBC2_1 2
29#define _STAT_VER_KERNEL64 3
30#define _STAT_VER_GLIBC2_3_4 3
31#define _STAT_VER_LINUX 3
32#define _STAT_VER _STAT_VER_LINUX
33
34/* Versions of the `xmknod' interface. */
35#define _MKNOD_VER_LINUX 0
36
37
38/* Nanosecond resolution timestamps are stored in a format equivalent to
39 'struct timespec'. This is the type used whenever possible but the
40 Unix namespace rules do not allow the identifier 'timespec' to appear
41 in the <sys/stat.h> header. Therefore we have to handle the use of
42 this header in strictly standard-compliant sources special.
43
44 Use neat tidy anonymous unions and structures when possible. */
45
46#ifdef __USE_XOPEN2K8
47# if __GNUC_PREREQ(3,3)
48# define __ST_TIME(X) \
49 __extension__ union { \
50 struct timespec st_##X##tim; \
51 struct { \
52 __time_t st_##X##time; \
53 unsigned long st_##X##timensec; \
54 }; \
55 }
56# else
57# define __ST_TIME(X) struct timespec st_##X##tim
58# define st_atime st_atim.tv_sec
59# define st_mtime st_mtim.tv_sec
60# define st_ctime st_ctim.tv_sec
61# endif
62#else
63# define __ST_TIME(X) \
64 __time_t st_##X##time; \
65 unsigned long st_##X##timensec
66#endif
67
68
69struct stat
70 {
71 __dev_t st_dev; /* Device. */
72#ifdef __USE_FILE_OFFSET64
73 __ino64_t st_ino; /* File serial number. */
74#else
75 __ino_t st_ino; /* File serial number. */
76 int __pad0; /* 64-bit st_ino. */
77#endif
78 __dev_t st_rdev; /* Device number, if device. */
79 __off_t st_size; /* Size of file, in bytes. */
80#ifdef __USE_FILE_OFFSET64
81 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
82#else
83 __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
84 int __pad1; /* 64-bit st_blocks. */
85#endif
86 __mode_t st_mode; /* File mode. */
87 __uid_t st_uid; /* User ID of the file's owner. */
88 __gid_t st_gid; /* Group ID of the file's group.*/
89 __blksize_t st_blksize; /* Optimal block size for I/O. */
90 __nlink_t st_nlink; /* Link count. */
91 int __pad2; /* Real padding. */
92 __ST_TIME(a); /* Time of last access. */
93 __ST_TIME(m); /* Time of last modification. */
94 __ST_TIME(c); /* Time of last status change. */
95 long __glibc_reserved[3];
96 };
97
98#ifdef __USE_LARGEFILE64
99/* Note stat64 is the same shape as stat. */
100struct stat64
101 {
102 __dev_t st_dev; /* Device. */
103 __ino64_t st_ino; /* File serial number. */
104 __dev_t st_rdev; /* Device number, if device. */
105 __off_t st_size; /* Size of file, in bytes. */
106 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
107 __mode_t st_mode; /* File mode. */
108 __uid_t st_uid; /* User ID of the file's owner. */
109 __gid_t st_gid; /* Group ID of the file's group.*/
110 __blksize_t st_blksize; /* Optimal block size for I/O. */
111 __nlink_t st_nlink; /* Link count. */
112 int __pad0; /* Real padding. */
113 __ST_TIME(a); /* Time of last access. */
114 __ST_TIME(m); /* Time of last modification. */
115 __ST_TIME(c); /* Time of last status change. */
116 long __glibc_reserved[3];
117 };
118#endif
119
120#undef __ST_TIME
121
122/* Tell code we have these members. */
123#define _STATBUF_ST_BLKSIZE
124#define _STATBUF_ST_RDEV
125#define _STATBUF_ST_NSEC
126
127/* Encoding of the file mode. */
128
129#define __S_IFMT 0170000 /* These bits determine file type. */
130
131/* File types. */
132#define __S_IFDIR 0040000 /* Directory. */
133#define __S_IFCHR 0020000 /* Character device. */
134#define __S_IFBLK 0060000 /* Block device. */
135#define __S_IFREG 0100000 /* Regular file. */
136#define __S_IFIFO 0010000 /* FIFO. */
137#define __S_IFLNK 0120000 /* Symbolic link. */
138#define __S_IFSOCK 0140000 /* Socket. */
139
140/* POSIX.1b objects. Note that these macros always evaluate to zero. But
141 they do it by enforcing the correct use of the macros. */
142#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
143#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
144#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
145
146/* Protection bits. */
147
148#define __S_ISUID 04000 /* Set user ID on execution. */
149#define __S_ISGID 02000 /* Set group ID on execution. */
150#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
151#define __S_IREAD 0400 /* Read by owner. */
152#define __S_IWRITE 0200 /* Write by owner. */
153#define __S_IEXEC 0100 /* Execute by owner. */
154
155#ifdef __USE_ATFILE
156# define UTIME_NOW ((1l << 30) - 1l)
157# define UTIME_OMIT ((1l << 30) - 2l)
158#endif
159
160#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h created+76
...@@ -0,0 +1,76 @@
1/* bits/typesizes.h -- underlying types for *_t. Linux/Alpha version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29#define __DEV_T_TYPE __U64_TYPE
30#define __UID_T_TYPE __U32_TYPE
31#define __GID_T_TYPE __U32_TYPE
32#define __INO_T_TYPE __U32_TYPE
33#define __INO64_T_TYPE __U64_TYPE
34#define __MODE_T_TYPE __U32_TYPE
35#define __NLINK_T_TYPE __U32_TYPE
36#define __OFF_T_TYPE __SLONGWORD_TYPE
37#define __OFF64_T_TYPE __S64_TYPE
38#define __PID_T_TYPE __S32_TYPE
39#define __RLIM_T_TYPE __ULONGWORD_TYPE
40#define __RLIM64_T_TYPE __U64_TYPE
41#define __BLKCNT_T_TYPE __U32_TYPE
42#define __BLKCNT64_T_TYPE __U64_TYPE
43#define __FSBLKCNT_T_TYPE __S32_TYPE
44#define __FSBLKCNT64_T_TYPE __S64_TYPE
45#define __FSFILCNT_T_TYPE __U32_TYPE
46#define __FSFILCNT64_T_TYPE __U64_TYPE
47#define __ID_T_TYPE __U32_TYPE
48#define __CLOCK_T_TYPE __SLONGWORD_TYPE
49#define __TIME_T_TYPE __SLONGWORD_TYPE
50#define __USECONDS_T_TYPE __U32_TYPE
51#define __SUSECONDS_T_TYPE __S64_TYPE
52#define __DADDR_T_TYPE __S32_TYPE
53#define __KEY_T_TYPE __S32_TYPE
54#define __CLOCKID_T_TYPE __S32_TYPE
55#define __TIMER_T_TYPE void *
56#define __BLKSIZE_T_TYPE __U32_TYPE
57#define __FSID_T_TYPE struct { int __val[2]; }
58#define __SSIZE_T_TYPE __SWORD_TYPE
59#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
60#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
61#define __CPU_MASK_TYPE __ULONGWORD_TYPE
62#define __FSWORD_T_TYPE __S32_TYPE
63
64/* Tell the libc code that off_t and off64_t are actually the same type
65 for all ABI purposes, even if possibly expressed as different base types
66 for C type-checking purposes. */
67#define __OFF_T_MATCHES_OFF64_T 1
68
69/* And for __rlim_t and __rlim64_t. */
70#define __RLIM_T_MATCHES_RLIM64_T 1
71
72/* Number of descriptors that can fit in an `fd_set'. */
73#define __FD_SETSIZE 1024
74
75
76#endif /* bits/typesizes.h */
libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h created+52
...@@ -0,0 +1,52 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 2010-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _KERNEL_FEATURES_H
21#define _KERNEL_FEATURES_H 1
22
23#include_next <kernel-features.h>
24
25/* There never has been support for fstat64. */
26#undef __ASSUME_STATFS64
27#define __ASSUME_STATFS64 0
28
29/* Alpha defines SysV ipc shmat syscall with a different name. */
30#define __NR_shmat __NR_osf_shmat
31
32#define __ASSUME_RECV_SYSCALL 1
33#define __ASSUME_SEND_SYSCALL 1
34
35/* Support for the renameat2 syscall was added in 3.17. */
36#if __LINUX_KERNEL_VERSION < 0x031100
37# undef __ASSUME_RENAMEAT2
38#endif
39
40/* Support for the execveat syscall was added in 4.2. */
41#if __LINUX_KERNEL_VERSION < 0x040200
42# undef __ASSUME_EXECVEAT
43#endif
44
45/* Support for copy_file_range, statx was added in kernel 4.13. */
46#if __LINUX_KERNEL_VERSION < 0x040D00
47# undef __ASSUME_MLOCK2
48# undef __ASSUME_COPY_FILE_RANGE
49# undef __ASSUME_STATX
50#endif
51
52#endif /* _KERNEL_FEATURES_H */
libc/glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h created+75
...@@ -0,0 +1,75 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_ALPHA_SYSDEP_H
20#define _LINUX_ALPHA_SYSDEP_H 1
21
22#ifdef __ASSEMBLER__
23#include <asm/pal.h>
24#include <alpha/regdef.h>
25#endif
26
27/* There is some commonality. */
28#include <sysdeps/unix/sysv/linux/sysdep.h>
29#include <sysdeps/unix/alpha/sysdep.h>
30
31#include <tls.h>
32
33/* For Linux we can use the system call table in the header file
34 /usr/include/asm/unistd.h
35 of the kernel. But these symbols do not follow the SYS_* syntax
36 so we have to redefine the `SYS_ify' macro here. */
37#undef SYS_ify
38#define SYS_ify(syscall_name) __NR_##syscall_name
39
40/* Define some aliases to make automatic syscall generation work
41 properly. The SYS_* variants are for the benefit of the files in
42 sysdeps/unix. */
43#define __NR_getpid __NR_getxpid
44#define __NR_getuid __NR_getxuid
45#define __NR_getgid __NR_getxgid
46#define SYS_getpid __NR_getxpid
47#define SYS_getuid __NR_getxuid
48#define SYS_getgid __NR_getxgid
49
50/*
51 * Some syscalls no Linux program should know about:
52 */
53#define __NR_osf_sigprocmask 48
54#define __NR_osf_shmat 209
55#define __NR_osf_getsysinfo 256
56#define __NR_osf_setsysinfo 257
57
58/* Help old kernel headers where particular syscalls are not available. */
59#ifndef __NR_semtimedop
60# define __NR_semtimedop 423
61#endif
62
63/* This is a kludge to make syscalls.list find these under the names
64 pread and pwrite, since some kernel headers define those names
65 and some define the *64 names for the same system calls. */
66#if !defined __NR_pread && defined __NR_pread64
67# define __NR_pread __NR_pread64
68#endif
69#if !defined __NR_pwrite && defined __NR_pwrite64
70# define __NR_pwrite __NR_pwrite64
71#endif
72
73#define SINGLE_THREAD_BY_GLOBAL 1
74
75#endif /* _LINUX_ALPHA_SYSDEP_H */
libc/glibc/sysdeps/unix/sysv/linux/arm/asm/unistd.h created+41
...@@ -0,0 +1,41 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * arch/arm/include/asm/unistd.h
4 *
5 * Copyright (C) 2001-2005 Russell King
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Please forward _all_ changes to this file to rmk@arm.linux.org.uk,
12 * no matter what the change is. Thanks!
13 */
14#ifndef _UAPI__ASM_ARM_UNISTD_H
15#define _UAPI__ASM_ARM_UNISTD_H
16
17#define __NR_OABI_SYSCALL_BASE 0x900000
18
19#if defined(__thumb__) || defined(__ARM_EABI__)
20#define __NR_SYSCALL_BASE 0
21#include <asm/unistd-eabi.h>
22#else
23#define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE
24#include <asm/unistd-oabi.h>
25#endif
26
27#include <asm/unistd-common.h>
28#define __NR_sync_file_range2 __NR_arm_sync_file_range
29
30/*
31 * The following SWIs are ARM private.
32 */
33#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
34#define __ARM_NR_breakpoint (__ARM_NR_BASE+1)
35#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
36#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
37#define __ARM_NR_usr32 (__ARM_NR_BASE+4)
38#define __ARM_NR_set_tls (__ARM_NR_BASE+5)
39#define __ARM_NR_get_tls (__ARM_NR_BASE+6)
40
41#endif /* _UAPI__ASM_ARM_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h created+52
...@@ -0,0 +1,52 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 2006-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include_next <kernel-features.h>
21
22/* The ARM kernel before 3.14.3 may or may not support
23 futex_atomic_cmpxchg_inatomic, depending on kernel
24 configuration. */
25#if __LINUX_KERNEL_VERSION < 0x030E03
26# undef __ASSUME_SET_ROBUST_LIST
27#endif
28
29/* ARM fadvise64_64 reorganize the syscall arguments. */
30#define __ASSUME_FADVISE64_64_6ARG 1
31
32/* Define this if your 32-bit syscall API requires 64-bit register
33 pairs to start with an even-number register. */
34#define __ASSUME_ALIGNED_REGISTER_PAIRS 1
35
36/* ARM only has a syscall for fadvise64{_64} and it is defined with a
37 non-standard name. */
38#define __NR_fadvise64_64 __NR_arm_fadvise64_64
39
40#define __ASSUME_RECV_SYSCALL 1
41#define __ASSUME_SEND_SYSCALL 1
42
43/* Support for the mlock2 and copy_file_range syscalls was added to
44 the compat syscall table for 64-bit kernels in 4.7, although
45 present in 32-bit kernels from 4.4 and 4.5 respectively. */
46#if __LINUX_KERNEL_VERSION < 0x040700
47# undef __ASSUME_MLOCK2
48# undef __ASSUME_COPY_FILE_RANGE
49#endif
50
51#undef __ASSUME_CLONE_DEFAULT
52#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/arm/sys/elf.h created+25
...@@ -0,0 +1,25 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_ELF_H
19#define _SYS_ELF_H 1
20
21#warning "This header is obsolete; use <sys/procfs.h> instead."
22
23#include <sys/procfs.h>
24
25#endif /* sys/elf.h */
libc/glibc/sysdeps/unix/sysv/linux/arm/sysdep.h created+447
...@@ -0,0 +1,447 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
4 ARM changes by Philip Blundell, <pjb27@cam.ac.uk>, May 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LINUX_ARM_SYSDEP_H
21#define _LINUX_ARM_SYSDEP_H 1
22
23/* Always enable vsyscalls on arm */
24#define ALWAYS_USE_VSYSCALL 1
25
26/* There is some commonality. */
27#include <sysdeps/unix/sysv/linux/sysdep.h>
28#include <sysdeps/unix/arm/sysdep.h>
29
30/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
31#include <dl-sysdep.h>
32
33#include <tls.h>
34
35/* In order to get __set_errno() definition in INLINE_SYSCALL. */
36#ifndef __ASSEMBLER__
37#include <errno.h>
38#endif
39
40/* For Linux we can use the system call table in the header file
41 /usr/include/asm/unistd.h
42 of the kernel. But these symbols do not follow the SYS_* syntax
43 so we have to redefine the `SYS_ify' macro here. */
44#undef SYS_ify
45#define SYS_ify(syscall_name) (__NR_##syscall_name)
46
47#include <bits/hwcap.h>
48
49#ifdef __ASSEMBLER__
50
51#ifndef ARCH_HAS_HARD_TP
52/* Internal macro calling the linux kernel kuser_get_tls helper.
53 Note that in thumb mode, a constant pool break is often out of range, so
54 we always expand the constant inline. */
55# ifdef __thumb2__
56# define GET_TLS_BODY \
57 movw r0, #0x0fe0; \
58 movt r0, #0xffff; \
59 blx r0
60# else
61# define GET_TLS_BODY \
62 mov r0, #0xffff0fff; /* Point to the high page. */ \
63 mov lr, pc; /* Save our return address. */ \
64 sub pc, r0, #31 /* Jump to the TLS entry. */
65# endif
66
67/* Helper to get the TLS base pointer. Save LR in TMP, return in R0,
68 and no other registers clobbered. TMP may be LR itself to indicate
69 that no save is necessary. */
70# undef GET_TLS
71# define GET_TLS(TMP) \
72 .ifnc TMP, lr; \
73 mov TMP, lr; \
74 cfi_register (lr, TMP); \
75 GET_TLS_BODY; \
76 mov lr, TMP; \
77 cfi_restore (lr); \
78 .else; \
79 GET_TLS_BODY; \
80 .endif
81#endif /* ARCH_HAS_HARD_TP */
82
83/* Linux uses a negative return value to indicate syscall errors,
84 unlike most Unices, which use the condition codes' carry flag.
85
86 Since version 2.1 the return value of a system call might be
87 negative even if the call succeeded. E.g., the `lseek' system call
88 might return a large offset. Therefore we must not anymore test
89 for < 0, but test for a real error by making sure the value in R0
90 is a real error number. Linus said he will make sure the no syscall
91 returns a value in -1 .. -4095 as a valid result so we can safely
92 test with -4095. */
93
94#undef PSEUDO
95#define PSEUDO(name, syscall_name, args) \
96 .text; \
97 ENTRY (name); \
98 DO_CALL (syscall_name, args); \
99 cmn r0, $4096;
100
101#define PSEUDO_RET \
102 it cc; \
103 RETINSTR(cc, lr); \
104 b PLTJMP(SYSCALL_ERROR)
105#undef ret
106#define ret PSEUDO_RET
107
108#undef PSEUDO_END
109#define PSEUDO_END(name) \
110 SYSCALL_ERROR_HANDLER; \
111 END (name)
112
113#undef PSEUDO_NOERRNO
114#define PSEUDO_NOERRNO(name, syscall_name, args) \
115 .text; \
116 ENTRY (name); \
117 DO_CALL (syscall_name, args);
118
119#define PSEUDO_RET_NOERRNO \
120 DO_RET (lr);
121
122#undef ret_NOERRNO
123#define ret_NOERRNO PSEUDO_RET_NOERRNO
124
125#undef PSEUDO_END_NOERRNO
126#define PSEUDO_END_NOERRNO(name) \
127 END (name)
128
129/* The function has to return the error code. */
130#undef PSEUDO_ERRVAL
131#define PSEUDO_ERRVAL(name, syscall_name, args) \
132 .text; \
133 ENTRY (name) \
134 DO_CALL (syscall_name, args); \
135 rsb r0, r0, #0
136
137#undef PSEUDO_END_ERRVAL
138#define PSEUDO_END_ERRVAL(name) \
139 END (name)
140
141#define ret_ERRVAL PSEUDO_RET_NOERRNO
142
143#if !IS_IN (libc)
144# define SYSCALL_ERROR __local_syscall_error
145# if RTLD_PRIVATE_ERRNO
146# define SYSCALL_ERROR_HANDLER \
147__local_syscall_error: \
148 rsb r0, r0, #0; \
149 LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno)); \
150 mvn r0, #0; \
151 DO_RET(lr)
152# else
153# if defined(__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__)
154# define POP_PC \
155 pop { lr }; \
156 cfi_adjust_cfa_offset (-4); \
157 cfi_restore (lr); \
158 bx lr
159# else
160# define POP_PC pop { pc }
161# endif
162# define SYSCALL_ERROR_HANDLER \
163__local_syscall_error: \
164 push { lr }; \
165 cfi_adjust_cfa_offset (4); \
166 cfi_rel_offset (lr, 0); \
167 push { r0 }; \
168 cfi_adjust_cfa_offset (4); \
169 bl PLTJMP(C_SYMBOL_NAME(__errno_location)); \
170 pop { r1 }; \
171 cfi_adjust_cfa_offset (-4); \
172 rsb r1, r1, #0; \
173 str r1, [r0]; \
174 mvn r0, #0; \
175 POP_PC;
176# endif
177#else
178# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
179# define SYSCALL_ERROR __syscall_error
180#endif
181
182/* The ARM EABI user interface passes the syscall number in r7, instead
183 of in the swi. This is more efficient, because the kernel does not need
184 to fetch the swi from memory to find out the number; which can be painful
185 with separate I-cache and D-cache. Make sure to use 0 for the SWI
186 argument; otherwise the (optional) compatibility code for APCS binaries
187 may be invoked. */
188
189/* Linux takes system call args in registers:
190 arg 1 r0
191 arg 2 r1
192 arg 3 r2
193 arg 4 r3
194 arg 5 r4 (this is different from the APCS convention)
195 arg 6 r5
196 arg 7 r6
197
198 The compiler is going to form a call by coming here, through PSEUDO, with
199 arguments
200 syscall number in the DO_CALL macro
201 arg 1 r0
202 arg 2 r1
203 arg 3 r2
204 arg 4 r3
205 arg 5 [sp]
206 arg 6 [sp+4]
207 arg 7 [sp+8]
208
209 We need to shuffle values between R4..R6 and the stack so that the
210 caller's v1..v3 and stack frame are not corrupted, and the kernel
211 sees the right arguments.
212
213*/
214
215/* We must save and restore r7 (call-saved) for the syscall number.
216 We never make function calls from inside here (only potentially
217 signal handlers), so we do not bother with doubleword alignment.
218
219 Just like the APCS syscall convention, the EABI syscall convention uses
220 r0 through r6 for up to seven syscall arguments. None are ever passed to
221 the kernel on the stack, although incoming arguments are on the stack for
222 syscalls with five or more arguments.
223
224 The assembler will convert the literal pool load to a move for most
225 syscalls. */
226
227#undef DO_CALL
228#define DO_CALL(syscall_name, args) \
229 DOARGS_##args; \
230 ldr r7, =SYS_ify (syscall_name); \
231 swi 0x0; \
232 UNDOARGS_##args
233
234#undef DOARGS_0
235#define DOARGS_0 \
236 .fnstart; \
237 push { r7 }; \
238 cfi_adjust_cfa_offset (4); \
239 cfi_rel_offset (r7, 0); \
240 .save { r7 }
241#undef DOARGS_1
242#define DOARGS_1 DOARGS_0
243#undef DOARGS_2
244#define DOARGS_2 DOARGS_0
245#undef DOARGS_3
246#define DOARGS_3 DOARGS_0
247#undef DOARGS_4
248#define DOARGS_4 DOARGS_0
249#undef DOARGS_5
250#define DOARGS_5 \
251 .fnstart; \
252 push {r4, r7}; \
253 cfi_adjust_cfa_offset (8); \
254 cfi_rel_offset (r4, 0); \
255 cfi_rel_offset (r7, 4); \
256 .save { r4, r7 }; \
257 ldr r4, [sp, #8]
258#undef DOARGS_6
259#define DOARGS_6 \
260 .fnstart; \
261 mov ip, sp; \
262 push {r4, r5, r7}; \
263 cfi_adjust_cfa_offset (12); \
264 cfi_rel_offset (r4, 0); \
265 cfi_rel_offset (r5, 4); \
266 cfi_rel_offset (r7, 8); \
267 .save { r4, r5, r7 }; \
268 ldmia ip, {r4, r5}
269#undef DOARGS_7
270#define DOARGS_7 \
271 .fnstart; \
272 mov ip, sp; \
273 push {r4, r5, r6, r7}; \
274 cfi_adjust_cfa_offset (16); \
275 cfi_rel_offset (r4, 0); \
276 cfi_rel_offset (r5, 4); \
277 cfi_rel_offset (r6, 8); \
278 cfi_rel_offset (r7, 12); \
279 .save { r4, r5, r6, r7 }; \
280 ldmia ip, {r4, r5, r6}
281
282#undef UNDOARGS_0
283#define UNDOARGS_0 \
284 pop {r7}; \
285 cfi_adjust_cfa_offset (-4); \
286 cfi_restore (r7); \
287 .fnend
288#undef UNDOARGS_1
289#define UNDOARGS_1 UNDOARGS_0
290#undef UNDOARGS_2
291#define UNDOARGS_2 UNDOARGS_0
292#undef UNDOARGS_3
293#define UNDOARGS_3 UNDOARGS_0
294#undef UNDOARGS_4
295#define UNDOARGS_4 UNDOARGS_0
296#undef UNDOARGS_5
297#define UNDOARGS_5 \
298 pop {r4, r7}; \
299 cfi_adjust_cfa_offset (-8); \
300 cfi_restore (r4); \
301 cfi_restore (r7); \
302 .fnend
303#undef UNDOARGS_6
304#define UNDOARGS_6 \
305 pop {r4, r5, r7}; \
306 cfi_adjust_cfa_offset (-12); \
307 cfi_restore (r4); \
308 cfi_restore (r5); \
309 cfi_restore (r7); \
310 .fnend
311#undef UNDOARGS_7
312#define UNDOARGS_7 \
313 pop {r4, r5, r6, r7}; \
314 cfi_adjust_cfa_offset (-16); \
315 cfi_restore (r4); \
316 cfi_restore (r5); \
317 cfi_restore (r6); \
318 cfi_restore (r7); \
319 .fnend
320
321#else /* not __ASSEMBLER__ */
322
323/* Define a macro which expands into the inline wrapper code for a system
324 call. */
325#undef INLINE_SYSCALL
326#define INLINE_SYSCALL(name, nr, args...) \
327 ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
328 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0)) \
329 { \
330 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
331 _sys_result = (unsigned int) -1; \
332 } \
333 (int) _sys_result; })
334
335#undef INTERNAL_SYSCALL_DECL
336#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
337
338#if defined(__thumb__)
339/* We can not expose the use of r7 to the compiler. GCC (as
340 of 4.5) uses r7 as the hard frame pointer for Thumb - although
341 for Thumb-2 it isn't obviously a better choice than r11.
342 And GCC does not support asms that conflict with the frame
343 pointer.
344
345 This would be easier if syscall numbers never exceeded 255,
346 but they do. For the moment the LOAD_ARGS_7 is sacrificed.
347 We can't use push/pop inside the asm because that breaks
348 unwinding (i.e. thread cancellation) for this frame. We can't
349 locally save and restore r7, because we do not know if this
350 function uses r7 or if it is our caller's r7; if it is our caller's,
351 then unwinding will fail higher up the stack. So we move the
352 syscall out of line and provide its own unwind information. */
353# undef INTERNAL_SYSCALL_RAW
354# define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
355 ({ \
356 register int _a1 asm ("a1"); \
357 int _nametmp = name; \
358 LOAD_ARGS_##nr (args) \
359 register int _name asm ("ip") = _nametmp; \
360 asm volatile ("bl __libc_do_syscall" \
361 : "=r" (_a1) \
362 : "r" (_name) ASM_ARGS_##nr \
363 : "memory", "lr"); \
364 _a1; })
365#else /* ARM */
366# undef INTERNAL_SYSCALL_RAW
367# define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
368 ({ \
369 register int _a1 asm ("r0"), _nr asm ("r7"); \
370 LOAD_ARGS_##nr (args) \
371 _nr = name; \
372 asm volatile ("swi 0x0 @ syscall " #name \
373 : "=r" (_a1) \
374 : "r" (_nr) ASM_ARGS_##nr \
375 : "memory"); \
376 _a1; })
377#endif
378
379#undef INTERNAL_SYSCALL
380#define INTERNAL_SYSCALL(name, err, nr, args...) \
381 INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
382
383#undef INTERNAL_SYSCALL_ARM
384#define INTERNAL_SYSCALL_ARM(name, err, nr, args...) \
385 INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
386
387#undef INTERNAL_SYSCALL_ERROR_P
388#define INTERNAL_SYSCALL_ERROR_P(val, err) \
389 ((unsigned int) (val) >= 0xfffff001u)
390
391#undef INTERNAL_SYSCALL_ERRNO
392#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
393
394/* List of system calls which are supported as vsyscalls. */
395#define HAVE_CLOCK_GETTIME_VSYSCALL 1
396#define HAVE_GETTIMEOFDAY_VSYSCALL 1
397
398#define LOAD_ARGS_0()
399#define ASM_ARGS_0
400#define LOAD_ARGS_1(a1) \
401 int _a1tmp = (int) (a1); \
402 LOAD_ARGS_0 () \
403 _a1 = _a1tmp;
404#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
405#define LOAD_ARGS_2(a1, a2) \
406 int _a2tmp = (int) (a2); \
407 LOAD_ARGS_1 (a1) \
408 register int _a2 asm ("a2") = _a2tmp;
409#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
410#define LOAD_ARGS_3(a1, a2, a3) \
411 int _a3tmp = (int) (a3); \
412 LOAD_ARGS_2 (a1, a2) \
413 register int _a3 asm ("a3") = _a3tmp;
414#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
415#define LOAD_ARGS_4(a1, a2, a3, a4) \
416 int _a4tmp = (int) (a4); \
417 LOAD_ARGS_3 (a1, a2, a3) \
418 register int _a4 asm ("a4") = _a4tmp;
419#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
420#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
421 int _v1tmp = (int) (a5); \
422 LOAD_ARGS_4 (a1, a2, a3, a4) \
423 register int _v1 asm ("v1") = _v1tmp;
424#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1)
425#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
426 int _v2tmp = (int) (a6); \
427 LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
428 register int _v2 asm ("v2") = _v2tmp;
429#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2)
430#ifndef __thumb__
431# define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
432 int _v3tmp = (int) (a7); \
433 LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) \
434 register int _v3 asm ("v3") = _v3tmp;
435# define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3)
436#endif
437
438/* For EABI, non-constant syscalls are actually pretty easy... */
439#undef INTERNAL_SYSCALL_NCS
440#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
441 INTERNAL_SYSCALL_RAW (number, err, nr, args)
442
443#define SINGLE_THREAD_BY_GLOBAL 1
444
445#endif /* __ASSEMBLER__ */
446
447#endif /* linux/arm/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/bits/param.h deleted-42
...@@ -1,42 +0,0 @@
1/* Old-style Unix parameters and limits. Linux version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
21#endif
22
23#ifndef ARG_MAX
24# define __undef_ARG_MAX
25#endif
26
27#include <linux/limits.h>
28#include <linux/param.h>
29
30/* The kernel headers define ARG_MAX. The value is wrong, though. */
31#ifdef __undef_ARG_MAX
32# undef ARG_MAX
33# undef __undef_ARG_MAX
34#endif
35
36#define MAXSYMLINKS 20
37
38/* The following are not really correct but it is a value we used for a
39 long time and which seems to be usable. People should not use NOFILE
40 and NCARGS anyway. */
41#define NOFILE 256
42#define NCARGS 131072
libc/glibc/sysdeps/unix/sysv/linux/bits/sched.h deleted-98
...@@ -1,98 +0,0 @@
1/* Definitions of constants and data structure for POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_SCHED_H
21#define _BITS_SCHED_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/sched.h> directly; use <sched.h> instead."
25#endif
26
27/* Scheduling algorithms. */
28#define SCHED_OTHER 0
29#define SCHED_FIFO 1
30#define SCHED_RR 2
31#ifdef __USE_GNU
32# define SCHED_BATCH 3
33# define SCHED_ISO 4
34# define SCHED_IDLE 5
35# define SCHED_DEADLINE 6
36
37# define SCHED_RESET_ON_FORK 0x40000000
38#endif
39
40#ifdef __USE_GNU
41/* Cloning flags. */
42# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
43# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
44# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */
45# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */
46# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */
47# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */
48# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to
49 wake it up on mm_release. */
50# define CLONE_PARENT 0x00008000 /* Set if we want to have the same
51 parent as the cloner. */
52# define CLONE_THREAD 0x00010000 /* Set to add to same thread group. */
53# define CLONE_NEWNS 0x00020000 /* Set to create new namespace. */
54# define CLONE_SYSVSEM 0x00040000 /* Set to shared SVID SEM_UNDO semantics. */
55# define CLONE_SETTLS 0x00080000 /* Set TLS info. */
56# define CLONE_PARENT_SETTID 0x00100000 /* Store TID in userlevel buffer
57 before MM copy. */
58# define CLONE_CHILD_CLEARTID 0x00200000 /* Register exit futex and memory
59 location to clear. */
60# define CLONE_DETACHED 0x00400000 /* Create clone detached. */
61# define CLONE_UNTRACED 0x00800000 /* Set if the tracing process can't
62 force CLONE_PTRACE on this clone. */
63# define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
64 the child. */
65# define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace. */
66# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
67# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
68# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
69# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
70# define CLONE_NEWNET 0x40000000 /* New network namespace. */
71# define CLONE_IO 0x80000000 /* Clone I/O context. */
72#endif
73
74#include <bits/types/struct_sched_param.h>
75
76__BEGIN_DECLS
77
78#ifdef __USE_GNU
79/* Clone current process. */
80extern int clone (int (*__fn) (void *__arg), void *__child_stack,
81 int __flags, void *__arg, ...) __THROW;
82
83/* Unshare the specified resources. */
84extern int unshare (int __flags) __THROW;
85
86/* Get index of currently used CPU. */
87extern int sched_getcpu (void) __THROW;
88
89/* Get currently used CPU and NUMA node. */
90extern int getcpu (unsigned int *, unsigned int *) __THROW;
91
92/* Switch process to namespace of type NSTYPE indicated by FD. */
93extern int setns (int __fd, int __nstype) __THROW;
94#endif
95
96__END_DECLS
97
98#endif /* bits/sched.h */
libc/glibc/sysdeps/unix/sysv/linux/bits/signum.h deleted-58
...@@ -1,58 +0,0 @@
1/* Signal number definitions. Linux version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_H
20#define _BITS_SIGNUM_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum.h> directly; use <signal.h> instead."
24#endif
25
26#include <bits/signum-generic.h>
27
28/* Adjustments and additions to the signal number constants for
29 most Linux systems. */
30
31#define SIGSTKFLT 16 /* Stack fault (obsolete). */
32#define SIGPWR 30 /* Power failure imminent. */
33
34#undef SIGBUS
35#define SIGBUS 7
36#undef SIGUSR1
37#define SIGUSR1 10
38#undef SIGUSR2
39#define SIGUSR2 12
40#undef SIGCHLD
41#define SIGCHLD 17
42#undef SIGCONT
43#define SIGCONT 18
44#undef SIGSTOP
45#define SIGSTOP 19
46#undef SIGTSTP
47#define SIGTSTP 20
48#undef SIGURG
49#define SIGURG 23
50#undef SIGPOLL
51#define SIGPOLL 29
52#undef SIGSYS
53#define SIGSYS 31
54
55#undef __SIGRTMAX
56#define __SIGRTMAX 64
57
58#endif /* <signal.h> included. */
libc/glibc/sysdeps/unix/sysv/linux/bits/time.h deleted-83
...@@ -1,83 +0,0 @@
1/* System-dependent timing definitions. Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <time.h> instead.
21 */
22
23#ifndef _BITS_TIME_H
24#define _BITS_TIME_H 1
25
26#include <bits/types.h>
27
28/* ISO/IEC 9899:1999 7.23.1: Components of time
29 The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
30 the number per second of the value returned by the `clock' function. */
31/* CAE XSH, Issue 4, Version 2: <time.h>
32 The value of CLOCKS_PER_SEC is required to be 1 million on all
33 XSI-conformant systems. */
34#define CLOCKS_PER_SEC ((__clock_t) 1000000)
35
36#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
37 && !defined __USE_XOPEN2K
38/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
39 presents the real value for clock ticks per second for the system. */
40extern long int __sysconf (int);
41# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
42#endif
43
44#ifdef __USE_POSIX199309
45/* Identifier for system-wide realtime clock. */
46# define CLOCK_REALTIME 0
47/* Monotonic system-wide clock. */
48# define CLOCK_MONOTONIC 1
49/* High-resolution timer from the CPU. */
50# define CLOCK_PROCESS_CPUTIME_ID 2
51/* Thread-specific CPU-time clock. */
52# define CLOCK_THREAD_CPUTIME_ID 3
53/* Monotonic system-wide clock, not adjusted for frequency scaling. */
54# define CLOCK_MONOTONIC_RAW 4
55/* Identifier for system-wide realtime clock, updated only on ticks. */
56# define CLOCK_REALTIME_COARSE 5
57/* Monotonic system-wide clock, updated only on ticks. */
58# define CLOCK_MONOTONIC_COARSE 6
59/* Monotonic system-wide clock that includes time spent in suspension. */
60# define CLOCK_BOOTTIME 7
61/* Like CLOCK_REALTIME but also wakes suspended system. */
62# define CLOCK_REALTIME_ALARM 8
63/* Like CLOCK_BOOTTIME but also wakes suspended system. */
64# define CLOCK_BOOTTIME_ALARM 9
65/* Like CLOCK_REALTIME but in International Atomic Time. */
66# define CLOCK_TAI 11
67
68/* Flag to indicate time is absolute. */
69# define TIMER_ABSTIME 1
70#endif
71
72#ifdef __USE_GNU
73# include <bits/timex.h>
74
75__BEGIN_DECLS
76
77/* Tune a POSIX clock. */
78extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
79
80__END_DECLS
81#endif /* use GNU */
82
83#endif /* bits/time.h */
libc/glibc/sysdeps/unix/sysv/linux/csky/asm/unistd.h created+10
...@@ -0,0 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3
4#define __ARCH_WANT_SYS_CLONE
5#include <asm-generic/unistd.h>
6
7#define __NR_set_thread_area (__NR_arch_specific_syscall + 0)
8__SYSCALL(__NR_set_thread_area, sys_set_thread_area)
9#define __NR_cacheflush (__NR_arch_specific_syscall + 1)
10__SYSCALL(__NR_cacheflush, sys_cacheflush)
libc/glibc/sysdeps/unix/sysv/linux/csky/kernel-features.h created+29
...@@ -0,0 +1,29 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 2018-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include_next <kernel-features.h>
21
22/* fadvise64_64 reorganize the syscall arguments. */
23#define __ASSUME_FADVISE64_64_6ARG 1
24
25/* Define this if your 32-bit syscall API requires 64-bit register
26 pairs to start with an even-number register. */
27#ifdef __CSKYABIV1__
28# define __ASSUME_ALIGNED_REGISTER_PAIRS 1
29#endif
libc/glibc/sysdeps/unix/sysv/linux/csky/sysdep.h created+534
...@@ -0,0 +1,534 @@
1/* Assembly macros for C-SKY.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_CSKY_SYSDEP_H
20#define _LINUX_CSKY_SYSDEP_H 1
21
22/* There is some commonality. */
23#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <sysdeps/csky/sysdep.h>
26
27/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
28#include <dl-sysdep.h>
29
30#include <tls.h>
31
32/* In order to get __set_errno() definition in INLINE_SYSCALL. */
33#ifndef __ASSEMBLER__
34# include <errno.h>
35#endif
36
37#undef SYS_ify
38#define SYS_ify(syscall_name) (__NR_##syscall_name)
39
40#ifdef __ASSEMBLER__
41/* Linux uses a negative return value to indicate syscall errors,
42 unlike most Unices, which use the condition codes' carry flag.
43
44 Since version 2.1 the return value of a system call might be
45 negative even if the call succeeded. E.g., the `lseek' system call
46 might return a large offset. Therefore we must not anymore test
47 for < 0, but test for a real error by making sure the value in R0
48 is a real error number. Linus said he will make sure the no syscall
49 returns a value in -1 .. -4095 as a valid result so we can safely
50 test with -4095. */
51
52# undef PSEUDO
53# define PSEUDO(name, syscall_name, args) \
54 .text; \
55 ENTRY (name); \
56 DO_CALL (syscall_name, args);
57
58# define GETGB \
59 grs t0, .Lgetpc; \
60.Lgetpc: \
61 lrw gb, .Lgetpc@GOTPC; \
62 addu gb, t0;
63
64# if IS_IN (libc)
65# ifdef __PIC__
66# define PSEUDO_RET \
67 btsti a0, 31; \
68 bf 1f; \
69 subi sp, 8; \
70 st.w lr, (sp); \
71 st.w gb, (sp, 4); \
72 GETGB; \
73 lrw a2, SYSCALL_ERROR@PLT; \
74 add a2, gb; \
75 ld.w a2, (a2); \
76 jsr a2; \
77 ld.w lr, (sp); \
78 ld.w gb, (sp, 4); \
79 addi sp, 8; \
801: \
81 rts
82# else
83# define PSEUDO_RET \
84 btsti a0, 31; \
85 bf 1f; \
86 jmpi SYSCALL_ERROR; \
871: \
88 rts
89# endif
90# else
91# ifdef __PIC__
92# define PSEUDO_RET \
93 btsti a0, 31; \
94 bf 1f; \
95 subi sp, 8; \
96 st.w lr, (sp); \
97 st.w gb, (sp, 4); \
98 GETGB; \
99 bsr SYSCALL_ERROR; \
100 ld.w lr, (sp); \
101 ld.w gb, (sp, 4); \
102 addi sp, 8; \
1031: \
104 rts
105# else
106# define PSEUDO_RET \
107 btsti a0, 31; \
108 bt SYSCALL_ERROR; \
109 rts
110# endif
111# endif
112
113# undef ret
114# define ret PSEUDO_RET
115
116# undef PSEUDO_END
117# define PSEUDO_END(name) \
118 .align 4; \
119 SYSCALL_ERROR_HANDLER; \
120 END (name)
121
122# undef PSEUDO_NOERRNO
123# define PSEUDO_NOERRNO(name, syscall_name, args) \
124 .text; \
125 ENTRY (name); \
126 DO_CALL (syscall_name, args)
127
128# define PSEUDO_RET_NOERRNO rts
129
130# undef ret_NOERRNO
131# define ret_NOERRNO PSEUDO_RET_NOERRNO
132
133# undef PSEUDO_END_NOERRNO
134# define PSEUDO_END_NOERRNO(name) END (name)
135
136/* The function has to return the error code. */
137# undef PSEUDO_ERRVAL
138# define PSEUDO_ERRVAL(name, syscall_name, args) \
139 .text; \
140 ENTRY (name) \
141 DO_CALL (syscall_name, args); \
142 not a0; \
143 addi a0, 1
144
145# undef PSEUDO_END_ERRVAL
146# define PSEUDO_END_ERRVAL(name) END (name)
147
148# define ret_ERRVAL rts
149
150# if !IS_IN (libc)
151# define SYSCALL_ERROR __local_syscall_error
152# if RTLD_PRIVATE_ERRNO
153# ifdef __PIC__
154# define SYSCALL_ERROR_HANDLER \
155__local_syscall_error: \
156 lrw a1, rtld_errno@PLT; \
157 addu a1, gb; \
158 ldw a1, (a1); \
159 rsubi a0, 0; \
160 stw a0, (a1); \
161 bmaski a0, 0; \
162 rts
163# else /* __PIC__ */
164# define SYSCALL_ERROR_HANDLER \
165__local_syscall_error: \
166 lrw a1, rtld_errno; \
167 rsubi a0, 0; \
168 stw a0, (a1); \
169 bmaski a0, 0; \
170 rts
171# endif /* __PIC__ */
172# else /* !RTLD_PRIVATE_ERRNO */
173# ifdef __PIC__
174# define SYSCALL_ERROR_HANDLER \
175__local_syscall_error: \
176 subi sp, 8; \
177 stw a0, (sp, 0); \
178 stw r15, (sp, 4); \
179 lrw a1, __errno_location@PLT; \
180 add a1, gb; \
181 ldw a1, (a1); \
182 jsr a1; \
183 ldw a1, (sp, 0); /* load errno*/ \
184 ldw r15, (sp, 4); \
185 addi sp, 8; \
186 movi a2, 0; \
187 rsub a1, a1, a2; \
188 stw a1, (a0); \
189 bmaski a0, 0; \
190 rts
191# else
192# define SYSCALL_ERROR_HANDLER \
193__local_syscall_error: \
194 subi sp, 8; \
195 stw a0, (sp, 0); \
196 stw r15, (sp, 4); \
197 lrw a1, __errno_location; \
198 jsr a1; \
199 ldw a1, (sp, 0); /* load errno */ \
200 ldw r15, (sp, 4); \
201 addi sp, 8; \
202 movi a2, 0; \
203 rsub a1, a1, a2; \
204 stw a1, (a0); \
205 bmaski a0, 0; \
206 rts
207# endif /* __PIC__ */
208# endif/* RTLD_PRIVATE_ERROR */
209# else
210# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
211# define SYSCALL_ERROR __syscall_error
212# endif/* IS_IN (libc) */
213
214/* define DO_CALL */
215# undef DO_CALL
216# define DO_CALL(syscall_name, args) \
217 DOARGS_##args; \
218 lrw r7, SYS_ify(syscall_name); \
219 trap 0; \
220 UNDOARGS_##args
221
222# undef DOARGS_0
223# define DOARGS_0 \
224 subi sp, 8; \
225 cfi_adjust_cfa_offset (8); \
226 stw r7, (sp, 0); \
227 cfi_rel_offset (r7, 0);
228
229# undef DOARGS_1
230# define DOARGS_1 DOARGS_0
231# undef DOARGS_2
232# define DOARGS_2 DOARGS_0
233# undef DOARGS_3
234# define DOARGS_3 DOARGS_0
235# undef DOARGS_4
236# define DOARGS_4 DOARGS_0
237# undef DOARGS_5
238# define DOARGS_5 \
239 subi sp, 8; \
240 cfi_adjust_cfa_offset (8); \
241 stw r7, (sp, 0); \
242 cfi_rel_offset (7, 0); \
243 stw r4, (sp, 4); \
244 cfi_rel_offset (4, 4); \
245 ldw r4, (sp, 8)
246# undef DOARGS_6
247# define DOARGS_6 \
248 subi sp, 16; \
249 cfi_adjust_cfa_offset (16); \
250 stw r7, (sp, 0); \
251 cfi_rel_offset (7, 0); \
252 stw r4, (sp, 4); \
253 cfi_rel_offset (4, 4); \
254 stw r5, (sp, 8); \
255 cfi_rel_offset (5, 8); \
256 ldw r4, (sp, 16); \
257 ldw r5, (sp, 20)
258
259# undef UNDOARGS_0
260# define UNDOARGS_0 \
261 ldw r7, (sp, 0); \
262 cfi_restore (r7); \
263 addi sp, 8; \
264 cfi_adjust_cfa_offset (-8);
265
266# undef UNDOARGS_1
267# define UNDOARGS_1 UNDOARGS_0
268# undef UNDOARGS_2
269# define UNDOARGS_2 UNDOARGS_0
270# undef UNDOARGS_3
271# define UNDOARGS_3 UNDOARGS_0
272# undef UNDOARGS_4
273# define UNDOARGS_4 UNDOARGS_0
274# undef UNDOARGS_5
275# define UNDOARGS_5 \
276 ldw r7, (sp, 0); \
277 cfi_restore (r4); \
278 ldw r4, (sp, 4); \
279 cfi_restore (r4); \
280 addi sp, 8; \
281 cfi_adjust_cfa_offset (-8);
282
283# undef UNDOARGS_6
284# define UNDOARGS_6 \
285 ldw r7, (sp, 0); \
286 cfi_restore (r7); \
287 ldw r4, (sp, 4); \
288 cfi_restore (r4); \
289 ldw r5, (sp, 8); \
290 cfi_restore (r5); \
291 addi sp, 16; \
292 cfi_adjust_cfa_offset (-16);
293
294#else /* not __ASSEMBLER__ */
295
296/* Define a macro which expands into the inline wrapper code for a system
297 call. */
298# undef INLINE_SYSCALL
299# define INLINE_SYSCALL(name, nr, args...) \
300 ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
301 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result,), 0)) \
302 { \
303 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
304 _sys_result = (unsigned int) -1; \
305 } \
306 (int) _sys_result; })
307
308# undef INTERNAL_SYSCALL_DECL
309# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
310
311# undef INTERNAL_SYSCALL_ERROR_P
312# define INTERNAL_SYSCALL_ERROR_P(val, err) \
313 ((unsigned int) (val) >= 0xffffff01u)
314
315# undef INTERNAL_SYSCALL_ERRNO
316# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
317
318# undef INTERNAL_SYSCALL_RAW
319# define INTERNAL_SYSCALL_RAW0(name, err, dummy...) \
320 ({unsigned int __sys_result; \
321 { \
322 register int _a1 __asm__ ("a0"), _nr __asm__ ("r7"); \
323 _nr = name; \
324 __asm__ __volatile__ ("trap 0 \n\t" \
325 : "=r" (_a1) \
326 : "r" (_nr) \
327 : "memory"); \
328 __sys_result = _a1; \
329 } \
330 (int) __sys_result; })
331
332# define INTERNAL_SYSCALL_RAW1(name, err, arg1) \
333 ({unsigned int __sys_result; \
334 register int _tmp_arg1 = (int)(arg1); \
335 { \
336 register int _a1 __asm__ ("a0"), _nr __asm__ ("r7"); \
337 _a1 = _tmp_arg1; \
338 _nr = name; \
339 __asm__ __volatile__ ("trap 0 \n\t" \
340 : "=r" (_a1) \
341 : "r" (_nr), "r" (_a1) \
342 : "memory"); \
343 __sys_result = _a1; \
344 } \
345 (int) __sys_result; })
346
347# define INTERNAL_SYSCALL_RAW2(name, err, arg1, arg2) \
348 ({unsigned int __sys_result; \
349 register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2); \
350 { \
351 register int _nr __asm__ ("r7"); \
352 register int _a1 __asm__ ("a0"), _a2 __asm__ ("a1"); \
353 _a1 = _tmp_arg1, _a2 = _tmp_arg2; \
354 _nr = name; \
355 __asm__ __volatile__ ("trap 0 \n\t" \
356 : "=r" (_a1) \
357 : "r" (_nr), "r" (_a1), "r" (_a2) \
358 : "memory"); \
359 __sys_result = _a1; \
360 } \
361 (int) __sys_result; })
362
363# define INTERNAL_SYSCALL_RAW3(name, err, arg1, arg2, arg3) \
364 ({unsigned int __sys_result; \
365 register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2); \
366 register int _tmp_arg3 = (int)(arg3); \
367 { \
368 register int _nr __asm__ ("r7"); \
369 register int _a1 __asm__ ("a0"), _a2 __asm__ ("a1"); \
370 register int _a3 __asm__ ("a2"); \
371 _a1 = _tmp_arg1; \
372 _a2 = _tmp_arg2; \
373 _a3 = _tmp_arg3; \
374 _nr = name; \
375 __asm__ __volatile__ ("trap 0 \n\t" \
376 : "=r" (_a1) \
377 : "r" (_nr), "r" (_a1), "r" (_a2), \
378 "r" (_a3) \
379 : "memory"); \
380 __sys_result = _a1; \
381 } \
382 (int) __sys_result; })
383
384# define INTERNAL_SYSCALL_RAW4(name, err, arg1, arg2, arg3, arg4) \
385 ({unsigned int __sys_result; \
386 register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2); \
387 register int _tmp_arg3 = (int)(arg3), _tmp_arg4 = (int)(arg4); \
388 { \
389 register int _nr __asm__ ("r7"); \
390 register int _a1 __asm__ ("a0"), _a2 __asm__ ("a1"); \
391 register int _a3 __asm__ ("a2"), _a4 __asm__ ("a3"); \
392 _a1 = _tmp_arg1, _a2 = _tmp_arg2, _a3 = _tmp_arg3; \
393 _a4 = _tmp_arg4; \
394 _nr = name; \
395 __asm__ __volatile__ ("trap 0 \n\t" \
396 : "=r" (_a1) \
397 : "r" (_nr), "r" (_a1), "r" (_a2), \
398 "r" (_a3), "r" (_a4) \
399 : "memory"); \
400 __sys_result = _a1; \
401 } \
402 (int) __sys_result; })
403
404# define INTERNAL_SYSCALL_RAW5(name, err, arg1, arg2, arg3, arg4, \
405 arg5) \
406 ({unsigned int __sys_result; \
407 register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2); \
408 register int _tmp_arg3 = (int)(arg3), _tmp_arg4 = (int)(arg4); \
409 register int _tmp_arg5 = (int)(arg5); \
410 { \
411 register int _nr __asm__ ("r7"); \
412 register int _a1 __asm__ ("a0"), _a2 __asm__ ("a1"); \
413 register int _a3 __asm__ ("a2"), _a4 __asm__ ("a3"); \
414 register int _a5 __asm__ ("r4"); \
415 _a1 = _tmp_arg1, _a2 = _tmp_arg2, _a3 = _tmp_arg3; \
416 _a4 = _tmp_arg4, _a5 = _tmp_arg5; \
417 _nr = name; \
418 __asm__ __volatile__ ("trap 0 \n\t" \
419 : "=r" (_a1) \
420 : "r" (_nr), "r" (_a1), "r" (_a2), \
421 "r" (_a3), "r" (_a4), "r" (_a5) \
422 : "memory"); \
423 __sys_result = _a1; \
424 } \
425 (int) __sys_result; })
426
427# define INTERNAL_SYSCALL_RAW6(name, err, arg1, arg2, arg3, arg4, \
428 arg5, arg6) \
429 ({unsigned int __sys_result; \
430 register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2); \
431 register int _tmp_arg3 = (int)(arg3), _tmp_arg4 = (int)(arg4); \
432 register int _tmp_arg5 = (int)(arg5), _tmp_arg6 = (int)(arg6); \
433 { \
434 register int _nr __asm__ ("r7"); \
435 register int _a1 __asm__ ("a0"), _a2 __asm__ ("a1"); \
436 register int _a3 __asm__ ("a2"), _a4 __asm__ ("a3"); \
437 register int _a5 __asm__ ("r4"), _a6 __asm__ ("r5"); \
438 _a1 = _tmp_arg1, _a2 = _tmp_arg2, _a3 = _tmp_arg3; \
439 _a4 = _tmp_arg4, _a5 = _tmp_arg5, _a6 = _tmp_arg6; \
440 _nr = name; \
441 __asm__ __volatile__ ("trap 0 \n\t" \
442 : "=r" (_a1) \
443 : "r" (_nr), "r" (_a1), "r" (_a2), \
444 "r" (_a3), "r" (_a4), "r" (_a5), \
445 "r" (_a6) \
446 : "memory"); \
447 __sys_result = _a1; \
448 } \
449 (int) __sys_result; })
450
451# define INTERNAL_SYSCALL_RAW7(name, err, arg1, arg2, arg3, arg4, \
452 arg5, arg6, arg7) \
453 ({unsigned int __sys_result; \
454 register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2); \
455 register int _tmp_arg3 = (int)(arg3), _tmp_arg4 = (int)(arg4); \
456 register int _tmp_arg5 = (int)(arg5), _tmp_arg6 = (int)(arg6); \
457 register int _tmp_arg7 = (int)(arg7); \
458 { \
459 register int _nr __asm__ ("r7"); \
460 register int _a1 __asm__ ("a0"), _a2 __asm__ ("a1"); \
461 register int _a3 __asm__ ("a2"), _a4 __asm__ ("a3"); \
462 register int _a5 __asm__ ("r4"), _a6 __asm__ ("r5"); \
463 register int _a7 __asm__ ("r6"); \
464 _a1 = _tmp_arg1, _a2 = _tmp_arg2, _a3 = _tmp_arg3; \
465 _a4 = _tmp_arg4, _a5 = _tmp_arg5, _a6 = _tmp_arg6; \
466 _a7 = _tmp_arg7; \
467 _nr = name; \
468 __asm__ __volatile__ ("trap 0 \n\t" \
469 : "=r" (_a1) \
470 : "r" (_nr), "r" (_a1), "r" (_a2), \
471 "r" (_a3), "r" (_a4), "r" (_a5), \
472 "r" (_a6), "r" (_a7) \
473 : "memory"); \
474 __sys_result = _a1; \
475 } \
476 (int) __sys_result; })
477
478# undef INTERNAL_SYSCALL
479# define INTERNAL_SYSCALL(name, err, nr, args...) \
480 INTERNAL_SYSCALL_RAW##nr(SYS_ify(name), err, args)
481
482# undef INTERNAL_SYSCALL_NCS
483# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
484 INTERNAL_SYSCALL_RAW##nr (number, err, args)
485
486#endif /* __ASSEMBLER__ */
487
488/* Pointer mangling support. */
489#if (IS_IN (rtld) || \
490 (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
491# ifdef __ASSEMBLER__
492# define PTR_MANGLE(dst, src, guard) \
493 grs t0, 1f; \
4941: \
495 lrw guard, 1b@GOTPC; \
496 addu t0, guard; \
497 lrw guard, __pointer_chk_guard_local@GOT; \
498 ldr.w guard, (t0, guard << 0); \
499 ldw guard, (guard, 0); \
500 xor dst, src, guard;
501# define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
502# define PTR_MANGLE2(dst, src, guard) \
503 xor dst, src, guard
504# define PTR_DEMANGLE2(dst, src, guard) PTR_MANGLE2 (dst, src, guard)
505# else
506extern uintptr_t __pointer_chk_guard_local;
507# define PTR_MANGLE(var) \
508 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
509# define PTR_DEMANGLE(var) PTR_MANGLE (var)
510# endif
511#else
512# ifdef __ASSEMBLER__
513# define PTR_MANGLE(dst, src, guard) \
514 grs t0, 1f; \
5151: \
516 lrw guard, 1b@GOTPC; \
517 addu t0, guard; \
518 lrw guard, __pointer_chk_guard@GOT; \
519 ldr.w guard, (t0, guard << 0); \
520 ldw guard, (guard, 0); \
521 xor dst, src, guard;
522# define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
523# define PTR_MANGLE2(dst, src, guard) \
524 xor dst, src, guard
525# define PTR_DEMANGLE2(dst, src, guard) PTR_MANGLE2 (dst, src, guard)
526# else
527extern uintptr_t __pointer_chk_guard;
528# define PTR_MANGLE(var) \
529 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
530# define PTR_DEMANGLE(var) PTR_MANGLE (var)
531# endif
532#endif
533
534#endif /* linux/csky/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/dl-sysdep.h created+33
...@@ -0,0 +1,33 @@
1/* System-specific settings for dynamic linker code. Linux version.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include_next <dl-sysdep.h>
20
21/* On many architectures the kernel provides a virtual DSO and gives
22 AT_SYSINFO_EHDR to point us to it. As this is introduced for new
23 machines, we should look at it for unwind information even if
24 we aren't making direct use of it. So enable this across the board. */
25
26#define NEED_DL_SYSINFO_DSO 1
27
28
29#ifndef __ASSEMBLER__
30/* Get version of the OS. */
31extern int _dl_discover_osversion (void) attribute_hidden;
32# define HAVE_DL_DISCOVER_OSVERSION 1
33#endif
libc/glibc/sysdeps/unix/sysv/linux/generic/bits/typesizes.h created+84
...@@ -0,0 +1,84 @@
1/* bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI.
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_TYPES_H
21# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
22#endif
23
24#ifndef _BITS_TYPESIZES_H
25#define _BITS_TYPESIZES_H 1
26
27/* See <bits/types.h> for the meaning of these macros. This file exists so
28 that <bits/types.h> need not vary across different GNU platforms. */
29
30#define __DEV_T_TYPE __UQUAD_TYPE
31#define __UID_T_TYPE __U32_TYPE
32#define __GID_T_TYPE __U32_TYPE
33#define __INO_T_TYPE __ULONGWORD_TYPE
34#define __INO64_T_TYPE __UQUAD_TYPE
35#define __MODE_T_TYPE __U32_TYPE
36#define __NLINK_T_TYPE __U32_TYPE
37#define __OFF_T_TYPE __SLONGWORD_TYPE
38#define __OFF64_T_TYPE __SQUAD_TYPE
39#define __PID_T_TYPE __S32_TYPE
40#define __RLIM_T_TYPE __ULONGWORD_TYPE
41#define __RLIM64_T_TYPE __UQUAD_TYPE
42#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
43#define __BLKCNT64_T_TYPE __SQUAD_TYPE
44#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
45#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
46#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
47#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
48#define __FSWORD_T_TYPE __SWORD_TYPE
49#define __ID_T_TYPE __U32_TYPE
50#define __CLOCK_T_TYPE __SLONGWORD_TYPE
51#define __TIME_T_TYPE __SLONGWORD_TYPE
52#define __USECONDS_T_TYPE __U32_TYPE
53#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
54#define __DADDR_T_TYPE __S32_TYPE
55#define __KEY_T_TYPE __S32_TYPE
56#define __CLOCKID_T_TYPE __S32_TYPE
57#define __TIMER_T_TYPE void *
58#define __BLKSIZE_T_TYPE __S32_TYPE
59#define __FSID_T_TYPE struct { int __val[2]; }
60#define __SSIZE_T_TYPE __SWORD_TYPE
61#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
62#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
63#define __CPU_MASK_TYPE __ULONGWORD_TYPE
64
65#ifdef __LP64__
66/* Tell the libc code that off_t and off64_t are actually the same type
67 for all ABI purposes, even if possibly expressed as different base types
68 for C type-checking purposes. */
69# define __OFF_T_MATCHES_OFF64_T 1
70
71/* Same for ino_t and ino64_t. */
72# define __INO_T_MATCHES_INO64_T 1
73
74/* And for __rlim_t and __rlim64_t. */
75# define __RLIM_T_MATCHES_RLIM64_T 1
76#else
77# define __RLIM_T_MATCHES_RLIM64_T 0
78#endif
79
80/* Number of descriptors that can fit in an `fd_set'. */
81#define __FD_SETSIZE 1024
82
83
84#endif /* bits/typesizes.h */
libc/glibc/sysdeps/unix/sysv/linux/generic/sysdep.h created+35
...@@ -0,0 +1,35 @@
1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <bits/wordsize.h>
20#include <kernel-features.h>
21#include <sysdeps/unix/sysdep.h>
22#include <sysdeps/unix/sysv/linux/sysdep.h>
23
24/* Provide the common name to allow more code reuse. */
25#ifdef __NR_llseek
26# define __NR__llseek __NR_llseek
27#endif
28
29#if __WORDSIZE == 64
30/* By defining the older names, glibc will build syscall wrappers for
31 both pread and pread64; sysdeps/unix/sysv/linux/wordsize-64/pread64.c
32 will suppress generating any separate code for pread64.c. */
33#define __NR_pread __NR_pread64
34#define __NR_pwrite __NR_pwrite64
35#endif
libc/glibc/sysdeps/unix/sysv/linux/hppa/kernel-features.h created+37
...@@ -0,0 +1,37 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 2006-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20
21/* Support for the utimes syscall was added in 3.14. */
22#if __LINUX_KERNEL_VERSION >= 0x030e00
23# define __ASSUME_UTIMES 1
24#endif
25
26#include_next <kernel-features.h>
27
28#define __ASSUME_RECV_SYSCALL 1
29#define __ASSUME_SEND_SYSCALL 1
30
31/* Support for the execveat syscall was added in 4.0. */
32#if __LINUX_KERNEL_VERSION < 0x040000
33# undef __ASSUME_EXECVEAT
34#endif
35
36#undef __ASSUME_CLONE_DEFAULT
37#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/hppa/pthread.h created+1138
...@@ -0,0 +1,1138 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _PTHREAD_H
19#define _PTHREAD_H 1
20
21#include <features.h>
22#include <endian.h>
23#include <sched.h>
24#include <time.h>
25
26#include <bits/pthreadtypes.h>
27#include <bits/setjmp.h>
28#include <bits/wordsize.h>
29#include <bits/types/struct_timespec.h>
30
31
32/* Detach state. */
33enum
34{
35 PTHREAD_CREATE_JOINABLE,
36#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
37 PTHREAD_CREATE_DETACHED
38#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
39};
40
41
42/* Mutex types. */
43enum
44{
45 PTHREAD_MUTEX_TIMED_NP,
46 PTHREAD_MUTEX_RECURSIVE_NP,
47 PTHREAD_MUTEX_ERRORCHECK_NP,
48 PTHREAD_MUTEX_ADAPTIVE_NP
49#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
50 ,
51 PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
52 PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
53 PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
54 PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
55#endif
56#ifdef __USE_GNU
57 /* For compatibility. */
58 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
59#endif
60};
61
62
63#ifdef __USE_XOPEN2K
64/* Robust mutex or not flags. */
65enum
66{
67 PTHREAD_MUTEX_STALLED,
68 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
69 PTHREAD_MUTEX_ROBUST,
70 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
71};
72#endif
73
74
75#if defined __USE_POSIX199506 || defined __USE_UNIX98
76/* Mutex protocols. */
77enum
78{
79 PTHREAD_PRIO_NONE,
80 PTHREAD_PRIO_INHERIT,
81 PTHREAD_PRIO_PROTECT
82};
83#endif
84
85
86#define PTHREAD_MUTEX_INITIALIZER \
87 { { 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, { __PTHREAD_SPINS }, { 0, 0 } } }
88#ifdef __USE_GNU
89# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
90 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, { 0, 0, 0, 0 }, 0, \
91 { __PTHREAD_SPINS }, { 0, 0 } } }
92# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
93 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, { 0, 0, 0, 0 }, 0, \
94 { __PTHREAD_SPINS }, { 0, 0 } } }
95# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
96 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, { 0, 0, 0, 0 }, 0, \
97 { __PTHREAD_SPINS }, { 0, 0 } } }
98#endif
99
100
101/* Read-write lock types. */
102#if defined __USE_UNIX98 || defined __USE_XOPEN2K
103enum
104{
105 PTHREAD_RWLOCK_PREFER_READER_NP,
106 PTHREAD_RWLOCK_PREFER_WRITER_NP,
107 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
108 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
109};
110
111/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t
112 has the shared field. All 64-bit architectures have the shared field
113 in pthread_rwlock_t. */
114#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
115# if __WORDSIZE == 64
116# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
117# endif
118#endif
119
120
121/* Read-write lock initializers. */
122# define PTHREAD_RWLOCK_INITIALIZER \
123 { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
124# ifdef __USE_GNU
125# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
126 { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
127 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, 0, 0, 0 } }
128# endif
129#endif /* Unix98 or XOpen2K */
130
131
132/* Scheduler inheritance. */
133enum
134{
135 PTHREAD_INHERIT_SCHED,
136#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
137 PTHREAD_EXPLICIT_SCHED
138#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
139};
140
141
142/* Scope handling. */
143enum
144{
145 PTHREAD_SCOPE_SYSTEM,
146#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
147 PTHREAD_SCOPE_PROCESS
148#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
149};
150
151
152/* Process shared or private flag. */
153enum
154{
155 PTHREAD_PROCESS_PRIVATE,
156#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
157 PTHREAD_PROCESS_SHARED
158#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
159};
160
161
162/* Conditional variable handling. */
163#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
164
165
166/* Cleanup buffers */
167struct _pthread_cleanup_buffer
168{
169 void (*__routine) (void *); /* Function to call. */
170 void *__arg; /* Its argument. */
171 int __canceltype; /* Saved cancellation type. */
172 struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
173};
174
175/* Cancellation */
176enum
177{
178 PTHREAD_CANCEL_ENABLE,
179#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
180 PTHREAD_CANCEL_DISABLE
181#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
182};
183enum
184{
185 PTHREAD_CANCEL_DEFERRED,
186#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
187 PTHREAD_CANCEL_ASYNCHRONOUS
188#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
189};
190#define PTHREAD_CANCELED ((void *) -1)
191
192
193/* Single execution handling. */
194#define PTHREAD_ONCE_INIT 0
195
196
197#ifdef __USE_XOPEN2K
198/* Value returned by 'pthread_barrier_wait' for one of the threads after
199 the required number of threads have called this function.
200 -1 is distinct from 0 and all errno constants */
201# define PTHREAD_BARRIER_SERIAL_THREAD -1
202#endif
203
204
205__BEGIN_DECLS
206
207/* Create a new thread, starting with execution of START-ROUTINE
208 getting passed ARG. Creation attributed come from ATTR. The new
209 handle is stored in *NEWTHREAD. */
210extern int pthread_create (pthread_t *__restrict __newthread,
211 const pthread_attr_t *__restrict __attr,
212 void *(*__start_routine) (void *),
213 void *__restrict __arg) __THROWNL __nonnull ((1, 3));
214
215/* Terminate calling thread.
216
217 The registered cleanup handlers are called via exception handling
218 so we cannot mark this function with __THROW.*/
219extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
220
221/* Make calling thread wait for termination of the thread TH. The
222 exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
223 is not NULL.
224
225 This function is a cancellation point and therefore not marked with
226 __THROW. */
227extern int pthread_join (pthread_t __th, void **__thread_return);
228
229#ifdef __USE_GNU
230/* Check whether thread TH has terminated. If yes return the status of
231 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
232extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
233
234/* Make calling thread wait for termination of the thread TH, but only
235 until TIMEOUT. The exit status of the thread is stored in
236 *THREAD_RETURN, if THREAD_RETURN is not NULL.
237
238 This function is a cancellation point and therefore not marked with
239 __THROW. */
240extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
241 const struct timespec *__abstime);
242#endif
243
244/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
245 The resources of TH will therefore be freed immediately when it
246 terminates, instead of waiting for another thread to perform PTHREAD_JOIN
247 on it. */
248extern int pthread_detach (pthread_t __th) __THROW;
249
250
251/* Obtain the identifier of the current thread. */
252extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
253
254/* Compare two thread identifiers. */
255extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
256 __THROW __attribute__ ((__const__));
257
258
259/* Thread attribute handling. */
260
261/* Initialize thread attribute *ATTR with default attributes
262 (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
263 no user-provided stack). */
264extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
265
266/* Destroy thread attribute *ATTR. */
267extern int pthread_attr_destroy (pthread_attr_t *__attr)
268 __THROW __nonnull ((1));
269
270/* Get detach state attribute. */
271extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
272 int *__detachstate)
273 __THROW __nonnull ((1, 2));
274
275/* Set detach state attribute. */
276extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
277 int __detachstate)
278 __THROW __nonnull ((1));
279
280
281/* Get the size of the guard area created for stack overflow protection. */
282extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
283 size_t *__guardsize)
284 __THROW __nonnull ((1, 2));
285
286/* Set the size of the guard area created for stack overflow protection. */
287extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
288 size_t __guardsize)
289 __THROW __nonnull ((1));
290
291
292/* Return in *PARAM the scheduling parameters of *ATTR. */
293extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
294 struct sched_param *__restrict __param)
295 __THROW __nonnull ((1, 2));
296
297/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
298extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
299 const struct sched_param *__restrict
300 __param) __THROW __nonnull ((1, 2));
301
302/* Return in *POLICY the scheduling policy of *ATTR. */
303extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
304 __attr, int *__restrict __policy)
305 __THROW __nonnull ((1, 2));
306
307/* Set scheduling policy in *ATTR according to POLICY. */
308extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
309 __THROW __nonnull ((1));
310
311/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
312extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
313 __attr, int *__restrict __inherit)
314 __THROW __nonnull ((1, 2));
315
316/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
317extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
318 int __inherit)
319 __THROW __nonnull ((1));
320
321
322/* Return in *SCOPE the scheduling contention scope of *ATTR. */
323extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
324 int *__restrict __scope)
325 __THROW __nonnull ((1, 2));
326
327/* Set scheduling contention scope in *ATTR according to SCOPE. */
328extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
329 __THROW __nonnull ((1));
330
331/* Return the previously set address for the stack. */
332extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
333 __attr, void **__restrict __stackaddr)
334 __THROW __nonnull ((1, 2)) __attribute_deprecated__;
335
336/* Set the starting address of the stack of the thread to be created.
337 Depending on whether the stack grows up or down the value must either
338 be higher or lower than all the address in the memory block. The
339 minimal size of the block must be PTHREAD_STACK_MIN. */
340extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
341 void *__stackaddr)
342 __THROW __nonnull ((1)) __attribute_deprecated__;
343
344/* Return the currently used minimal stack size. */
345extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
346 __attr, size_t *__restrict __stacksize)
347 __THROW __nonnull ((1, 2));
348
349/* Add information about the minimum stack size needed for the thread
350 to be started. This size must never be less than PTHREAD_STACK_MIN
351 and must also not exceed the system limits. */
352extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
353 size_t __stacksize)
354 __THROW __nonnull ((1));
355
356#ifdef __USE_XOPEN2K
357/* Return the previously set address for the stack. */
358extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
359 void **__restrict __stackaddr,
360 size_t *__restrict __stacksize)
361 __THROW __nonnull ((1, 2, 3));
362
363/* The following two interfaces are intended to replace the last two. They
364 require setting the address as well as the size since only setting the
365 address will make the implementation on some architectures impossible. */
366extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
367 size_t __stacksize) __THROW __nonnull ((1));
368#endif
369
370#ifdef __USE_GNU
371/* Thread created with attribute ATTR will be limited to run only on
372 the processors represented in CPUSET. */
373extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
374 size_t __cpusetsize,
375 const cpu_set_t *__cpuset)
376 __THROW __nonnull ((1, 3));
377
378/* Get bit set in CPUSET representing the processors threads created with
379 ATTR can run on. */
380extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
381 size_t __cpusetsize,
382 cpu_set_t *__cpuset)
383 __THROW __nonnull ((1, 3));
384
385/* Get the default attributes used by pthread_create in this process. */
386extern int pthread_getattr_default_np (pthread_attr_t *__attr)
387 __THROW __nonnull ((1));
388
389/* Set the default attributes to be used by pthread_create in this
390 process. */
391extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
392 __THROW __nonnull ((1));
393
394/* Initialize thread attribute *ATTR with attributes corresponding to the
395 already running thread TH. It shall be called on uninitialized ATTR
396 and destroyed with pthread_attr_destroy when no longer needed. */
397extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
398 __THROW __nonnull ((2));
399#endif
400
401
402/* Functions for scheduling control. */
403
404/* Set the scheduling parameters for TARGET_THREAD according to POLICY
405 and *PARAM. */
406extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
407 const struct sched_param *__param)
408 __THROW __nonnull ((3));
409
410/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
411extern int pthread_getschedparam (pthread_t __target_thread,
412 int *__restrict __policy,
413 struct sched_param *__restrict __param)
414 __THROW __nonnull ((2, 3));
415
416/* Set the scheduling priority for TARGET_THREAD. */
417extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
418 __THROW;
419
420
421#ifdef __USE_GNU
422/* Get thread name visible in the kernel and its interfaces. */
423extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
424 size_t __buflen)
425 __THROW __nonnull ((2));
426
427/* Set thread name visible in the kernel and its interfaces. */
428extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
429 __THROW __nonnull ((2));
430#endif
431
432
433#ifdef __USE_UNIX98
434/* Determine level of concurrency. */
435extern int pthread_getconcurrency (void) __THROW;
436
437/* Set new concurrency level to LEVEL. */
438extern int pthread_setconcurrency (int __level) __THROW;
439#endif
440
441#ifdef __USE_GNU
442/* Yield the processor to another thread or process.
443 This function is similar to the POSIX `sched_yield' function but
444 might be differently implemented in the case of a m-on-n thread
445 implementation. */
446extern int pthread_yield (void) __THROW;
447
448
449/* Limit specified thread TH to run only on the processors represented
450 in CPUSET. */
451extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
452 const cpu_set_t *__cpuset)
453 __THROW __nonnull ((3));
454
455/* Get bit set in CPUSET representing the processors TH can run on. */
456extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
457 cpu_set_t *__cpuset)
458 __THROW __nonnull ((3));
459#endif
460
461
462/* Functions for handling initialization. */
463
464/* Guarantee that the initialization function INIT_ROUTINE will be called
465 only once, even if pthread_once is executed several times with the
466 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
467 extern variable initialized to PTHREAD_ONCE_INIT.
468
469 The initialization functions might throw exception which is why
470 this function is not marked with __THROW. */
471extern int pthread_once (pthread_once_t *__once_control,
472 void (*__init_routine) (void)) __nonnull ((1, 2));
473
474
475/* Functions for handling cancellation.
476
477 Note that these functions are explicitly not marked to not throw an
478 exception in C++ code. If cancellation is implemented by unwinding
479 this is necessary to have the compiler generate the unwind information. */
480
481/* Set cancelability state of current thread to STATE, returning old
482 state in *OLDSTATE if OLDSTATE is not NULL. */
483extern int pthread_setcancelstate (int __state, int *__oldstate);
484
485/* Set cancellation state of current thread to TYPE, returning the old
486 type in *OLDTYPE if OLDTYPE is not NULL. */
487extern int pthread_setcanceltype (int __type, int *__oldtype);
488
489/* Cancel THREAD immediately or at the next possibility. */
490extern int pthread_cancel (pthread_t __th);
491
492/* Test for pending cancellation for the current thread and terminate
493 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
494 cancelled. */
495extern void pthread_testcancel (void);
496
497
498/* Cancellation handling with integration into exception handling. */
499
500typedef struct
501{
502 struct
503 {
504 __jmp_buf __cancel_jmp_buf;
505 int __mask_was_saved;
506 } __cancel_jmp_buf[1];
507 void *__pad[4];
508} __pthread_unwind_buf_t __attribute__ ((__aligned__));
509
510/* No special attributes by default. */
511#ifndef __cleanup_fct_attribute
512# define __cleanup_fct_attribute
513#endif
514
515
516/* Structure to hold the cleanup handler information. */
517struct __pthread_cleanup_frame
518{
519 void (*__cancel_routine) (void *);
520 void *__cancel_arg;
521 int __do_it;
522 int __cancel_type;
523};
524
525#if defined __GNUC__ && defined __EXCEPTIONS
526# ifdef __cplusplus
527/* Class to handle cancellation handler invocation. */
528class __pthread_cleanup_class
529{
530 void (*__cancel_routine) (void *);
531 void *__cancel_arg;
532 int __do_it;
533 int __cancel_type;
534
535 public:
536 __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
537 : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
538 ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
539 void __setdoit (int __newval) { __do_it = __newval; }
540 void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
541 &__cancel_type); }
542 void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
543};
544
545/* Install a cleanup handler: ROUTINE will be called with arguments ARG
546 when the thread is canceled or calls pthread_exit. ROUTINE will also
547 be called with arguments ARG when the matching pthread_cleanup_pop
548 is executed with non-zero EXECUTE argument.
549
550 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
551 be used in matching pairs at the same nesting level of braces. */
552# define pthread_cleanup_push(routine, arg) \
553 do { \
554 __pthread_cleanup_class __clframe (routine, arg)
555
556/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
557 If EXECUTE is non-zero, the handler function is called. */
558# define pthread_cleanup_pop(execute) \
559 __clframe.__setdoit (execute); \
560 } while (0)
561
562# ifdef __USE_GNU
563/* Install a cleanup handler as pthread_cleanup_push does, but also
564 saves the current cancellation type and sets it to deferred
565 cancellation. */
566# define pthread_cleanup_push_defer_np(routine, arg) \
567 do { \
568 __pthread_cleanup_class __clframe (routine, arg); \
569 __clframe.__defer ()
570
571/* Remove a cleanup handler as pthread_cleanup_pop does, but also
572 restores the cancellation type that was in effect when the matching
573 pthread_cleanup_push_defer was called. */
574# define pthread_cleanup_pop_restore_np(execute) \
575 __clframe.__restore (); \
576 __clframe.__setdoit (execute); \
577 } while (0)
578# endif
579# else
580/* Function called to call the cleanup handler. As an extern inline
581 function the compiler is free to decide inlining the change when
582 needed or fall back on the copy which must exist somewhere
583 else. */
584__extern_inline void
585__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
586{
587 if (__frame->__do_it)
588 __frame->__cancel_routine (__frame->__cancel_arg);
589}
590
591/* Install a cleanup handler: ROUTINE will be called with arguments ARG
592 when the thread is canceled or calls pthread_exit. ROUTINE will also
593 be called with arguments ARG when the matching pthread_cleanup_pop
594 is executed with non-zero EXECUTE argument.
595
596 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
597 be used in matching pairs at the same nesting level of braces. */
598# define pthread_cleanup_push(routine, arg) \
599 do { \
600 struct __pthread_cleanup_frame __clframe \
601 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
602 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
603 .__do_it = 1 };
604
605/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
606 If EXECUTE is non-zero, the handler function is called. */
607# define pthread_cleanup_pop(execute) \
608 __clframe.__do_it = (execute); \
609 } while (0)
610
611# ifdef __USE_GNU
612/* Install a cleanup handler as pthread_cleanup_push does, but also
613 saves the current cancellation type and sets it to deferred
614 cancellation. */
615# define pthread_cleanup_push_defer_np(routine, arg) \
616 do { \
617 struct __pthread_cleanup_frame __clframe \
618 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
619 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
620 .__do_it = 1 }; \
621 (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
622 &__clframe.__cancel_type)
623
624/* Remove a cleanup handler as pthread_cleanup_pop does, but also
625 restores the cancellation type that was in effect when the matching
626 pthread_cleanup_push_defer was called. */
627# define pthread_cleanup_pop_restore_np(execute) \
628 (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
629 __clframe.__do_it = (execute); \
630 } while (0)
631# endif
632# endif
633#else
634/* Install a cleanup handler: ROUTINE will be called with arguments ARG
635 when the thread is canceled or calls pthread_exit. ROUTINE will also
636 be called with arguments ARG when the matching pthread_cleanup_pop
637 is executed with non-zero EXECUTE argument.
638
639 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
640 be used in matching pairs at the same nesting level of braces. */
641# define pthread_cleanup_push(routine, arg) \
642 do { \
643 __pthread_unwind_buf_t __cancel_buf; \
644 void (*__cancel_routine) (void *) = (routine); \
645 void *__cancel_arg = (arg); \
646 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
647 __cancel_buf.__cancel_jmp_buf, 0); \
648 if (__glibc_unlikely (__not_first_call)) \
649 { \
650 __cancel_routine (__cancel_arg); \
651 __pthread_unwind_next (&__cancel_buf); \
652 /* NOTREACHED */ \
653 } \
654 \
655 __pthread_register_cancel (&__cancel_buf); \
656 do {
657extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
658 __cleanup_fct_attribute;
659
660/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
661 If EXECUTE is non-zero, the handler function is called. */
662# define pthread_cleanup_pop(execute) \
663 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
664 } while (0); \
665 __pthread_unregister_cancel (&__cancel_buf); \
666 if (execute) \
667 __cancel_routine (__cancel_arg); \
668 } while (0)
669extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
670 __cleanup_fct_attribute;
671
672# ifdef __USE_GNU
673/* Install a cleanup handler as pthread_cleanup_push does, but also
674 saves the current cancellation type and sets it to deferred
675 cancellation. */
676# define pthread_cleanup_push_defer_np(routine, arg) \
677 do { \
678 __pthread_unwind_buf_t __cancel_buf; \
679 void (*__cancel_routine) (void *) = (routine); \
680 void *__cancel_arg = (arg); \
681 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
682 __cancel_buf.__cancel_jmp_buf, 0); \
683 if (__glibc_unlikely (__not_first_call)) \
684 { \
685 __cancel_routine (__cancel_arg); \
686 __pthread_unwind_next (&__cancel_buf); \
687 /* NOTREACHED */ \
688 } \
689 \
690 __pthread_register_cancel_defer (&__cancel_buf); \
691 do {
692extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
693 __cleanup_fct_attribute;
694
695/* Remove a cleanup handler as pthread_cleanup_pop does, but also
696 restores the cancellation type that was in effect when the matching
697 pthread_cleanup_push_defer was called. */
698# define pthread_cleanup_pop_restore_np(execute) \
699 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
700 } while (0); \
701 __pthread_unregister_cancel_restore (&__cancel_buf); \
702 if (execute) \
703 __cancel_routine (__cancel_arg); \
704 } while (0)
705extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
706 __cleanup_fct_attribute;
707# endif
708
709/* Internal interface to initiate cleanup. */
710extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
711 __cleanup_fct_attribute __attribute__ ((__noreturn__))
712# ifndef SHARED
713 __attribute__ ((__weak__))
714# endif
715 ;
716#endif
717
718/* Function used in the macros. */
719struct __jmp_buf_tag;
720extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
721
722
723/* Mutex handling. */
724
725/* Initialize a mutex. */
726extern int pthread_mutex_init (pthread_mutex_t *__mutex,
727 const pthread_mutexattr_t *__mutexattr)
728 __THROW __nonnull ((1));
729
730/* Destroy a mutex. */
731extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
732 __THROW __nonnull ((1));
733
734/* Try locking a mutex. */
735extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
736 __THROWNL __nonnull ((1));
737
738/* Lock a mutex. */
739extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
740 __THROWNL __nonnull ((1));
741
742#ifdef __USE_XOPEN2K
743/* Wait until lock becomes available, or specified time passes. */
744extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
745 const struct timespec *__restrict
746 __abstime) __THROWNL __nonnull ((1, 2));
747#endif
748
749/* Unlock a mutex. */
750extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
751 __THROWNL __nonnull ((1));
752
753
754/* Get the priority ceiling of MUTEX. */
755extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
756 __restrict __mutex,
757 int *__restrict __prioceiling)
758 __THROW __nonnull ((1, 2));
759
760/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
761 priority ceiling value in *OLD_CEILING. */
762extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
763 int __prioceiling,
764 int *__restrict __old_ceiling)
765 __THROW __nonnull ((1, 3));
766
767
768#ifdef __USE_XOPEN2K8
769/* Declare the state protected by MUTEX as consistent. */
770extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
771 __THROW __nonnull ((1));
772# ifdef __USE_GNU
773extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
774 __THROW __nonnull ((1));
775# endif
776#endif
777
778
779/* Functions for handling mutex attributes. */
780
781/* Initialize mutex attribute object ATTR with default attributes
782 (kind is PTHREAD_MUTEX_TIMED_NP). */
783extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
784 __THROW __nonnull ((1));
785
786/* Destroy mutex attribute object ATTR. */
787extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
788 __THROW __nonnull ((1));
789
790/* Get the process-shared flag of the mutex attribute ATTR. */
791extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
792 __restrict __attr,
793 int *__restrict __pshared)
794 __THROW __nonnull ((1, 2));
795
796/* Set the process-shared flag of the mutex attribute ATTR. */
797extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
798 int __pshared)
799 __THROW __nonnull ((1));
800
801#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
802/* Return in *KIND the mutex kind attribute in *ATTR. */
803extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
804 __attr, int *__restrict __kind)
805 __THROW __nonnull ((1, 2));
806
807/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
808 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
809 PTHREAD_MUTEX_DEFAULT). */
810extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
811 __THROW __nonnull ((1));
812#endif
813
814/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
815extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
816 __restrict __attr,
817 int *__restrict __protocol)
818 __THROW __nonnull ((1, 2));
819
820/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
821 PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
822extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
823 int __protocol)
824 __THROW __nonnull ((1));
825
826/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
827extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
828 __restrict __attr,
829 int *__restrict __prioceiling)
830 __THROW __nonnull ((1, 2));
831
832/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
833extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
834 int __prioceiling)
835 __THROW __nonnull ((1));
836
837#ifdef __USE_XOPEN2K
838/* Get the robustness flag of the mutex attribute ATTR. */
839extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
840 int *__robustness)
841 __THROW __nonnull ((1, 2));
842# ifdef __USE_GNU
843extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
844 int *__robustness)
845 __THROW __nonnull ((1, 2));
846# endif
847
848/* Set the robustness flag of the mutex attribute ATTR. */
849extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
850 int __robustness)
851 __THROW __nonnull ((1));
852# ifdef __USE_GNU
853extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
854 int __robustness)
855 __THROW __nonnull ((1));
856# endif
857#endif
858
859
860#if defined __USE_UNIX98 || defined __USE_XOPEN2K
861/* Functions for handling read-write locks. */
862
863/* Initialize read-write lock RWLOCK using attributes ATTR, or use
864 the default values if later is NULL. */
865extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
866 const pthread_rwlockattr_t *__restrict
867 __attr) __THROW __nonnull ((1));
868
869/* Destroy read-write lock RWLOCK. */
870extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
871 __THROW __nonnull ((1));
872
873/* Acquire read lock for RWLOCK. */
874extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
875 __THROWNL __nonnull ((1));
876
877/* Try to acquire read lock for RWLOCK. */
878extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
879 __THROWNL __nonnull ((1));
880
881# ifdef __USE_XOPEN2K
882/* Try to acquire read lock for RWLOCK or return after specfied time. */
883extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
884 const struct timespec *__restrict
885 __abstime) __THROWNL __nonnull ((1, 2));
886# endif
887
888/* Acquire write lock for RWLOCK. */
889extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
890 __THROWNL __nonnull ((1));
891
892/* Try to acquire write lock for RWLOCK. */
893extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
894 __THROWNL __nonnull ((1));
895
896# ifdef __USE_XOPEN2K
897/* Try to acquire write lock for RWLOCK or return after specfied time. */
898extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
899 const struct timespec *__restrict
900 __abstime) __THROWNL __nonnull ((1, 2));
901# endif
902
903/* Unlock RWLOCK. */
904extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
905 __THROWNL __nonnull ((1));
906
907
908/* Functions for handling read-write lock attributes. */
909
910/* Initialize attribute object ATTR with default values. */
911extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
912 __THROW __nonnull ((1));
913
914/* Destroy attribute object ATTR. */
915extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
916 __THROW __nonnull ((1));
917
918/* Return current setting of process-shared attribute of ATTR in PSHARED. */
919extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
920 __restrict __attr,
921 int *__restrict __pshared)
922 __THROW __nonnull ((1, 2));
923
924/* Set process-shared attribute of ATTR to PSHARED. */
925extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
926 int __pshared)
927 __THROW __nonnull ((1));
928
929/* Return current setting of reader/writer preference. */
930extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
931 __restrict __attr,
932 int *__restrict __pref)
933 __THROW __nonnull ((1, 2));
934
935/* Set reader/write preference. */
936extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
937 int __pref) __THROW __nonnull ((1));
938#endif
939
940
941/* Functions for handling conditional variables. */
942
943/* Initialize condition variable COND using attributes ATTR, or use
944 the default values if later is NULL. */
945extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
946 const pthread_condattr_t *__restrict __cond_attr)
947 __THROW __nonnull ((1));
948
949/* Destroy condition variable COND. */
950extern int pthread_cond_destroy (pthread_cond_t *__cond)
951 __THROW __nonnull ((1));
952
953/* Wake up one thread waiting for condition variable COND. */
954extern int pthread_cond_signal (pthread_cond_t *__cond)
955 __THROWNL __nonnull ((1));
956
957/* Wake up all threads waiting for condition variables COND. */
958extern int pthread_cond_broadcast (pthread_cond_t *__cond)
959 __THROWNL __nonnull ((1));
960
961/* Wait for condition variable COND to be signaled or broadcast.
962 MUTEX is assumed to be locked before.
963
964 This function is a cancellation point and therefore not marked with
965 __THROW. */
966extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
967 pthread_mutex_t *__restrict __mutex)
968 __nonnull ((1, 2));
969
970/* Wait for condition variable COND to be signaled or broadcast until
971 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
972 absolute time specification; zero is the beginning of the epoch
973 (00:00:00 GMT, January 1, 1970).
974
975 This function is a cancellation point and therefore not marked with
976 __THROW. */
977extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
978 pthread_mutex_t *__restrict __mutex,
979 const struct timespec *__restrict __abstime)
980 __nonnull ((1, 2, 3));
981
982/* Functions for handling condition variable attributes. */
983
984/* Initialize condition variable attribute ATTR. */
985extern int pthread_condattr_init (pthread_condattr_t *__attr)
986 __THROW __nonnull ((1));
987
988/* Destroy condition variable attribute ATTR. */
989extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
990 __THROW __nonnull ((1));
991
992/* Get the process-shared flag of the condition variable attribute ATTR. */
993extern int pthread_condattr_getpshared (const pthread_condattr_t *
994 __restrict __attr,
995 int *__restrict __pshared)
996 __THROW __nonnull ((1, 2));
997
998/* Set the process-shared flag of the condition variable attribute ATTR. */
999extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1000 int __pshared) __THROW __nonnull ((1));
1001
1002#ifdef __USE_XOPEN2K
1003/* Get the clock selected for the condition variable attribute ATTR. */
1004extern int pthread_condattr_getclock (const pthread_condattr_t *
1005 __restrict __attr,
1006 __clockid_t *__restrict __clock_id)
1007 __THROW __nonnull ((1, 2));
1008
1009/* Set the clock selected for the condition variable attribute ATTR. */
1010extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1011 __clockid_t __clock_id)
1012 __THROW __nonnull ((1));
1013#endif
1014
1015
1016#ifdef __USE_XOPEN2K
1017/* Functions to handle spinlocks. */
1018
1019/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
1020 be shared between different processes. */
1021extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1022 __THROW __nonnull ((1));
1023
1024/* Destroy the spinlock LOCK. */
1025extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1026 __THROW __nonnull ((1));
1027
1028/* Wait until spinlock LOCK is retrieved. */
1029extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1030 __THROWNL __nonnull ((1));
1031
1032/* Try to lock spinlock LOCK. */
1033extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1034 __THROWNL __nonnull ((1));
1035
1036/* Release spinlock LOCK. */
1037extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1038 __THROWNL __nonnull ((1));
1039
1040
1041/* Functions to handle barriers. */
1042
1043/* Initialize BARRIER with the attributes in ATTR. The barrier is
1044 opened when COUNT waiters arrived. */
1045extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1046 const pthread_barrierattr_t *__restrict
1047 __attr, unsigned int __count)
1048 __THROW __nonnull ((1));
1049
1050/* Destroy a previously dynamically initialized barrier BARRIER. */
1051extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1052 __THROW __nonnull ((1));
1053
1054/* Wait on barrier BARRIER. */
1055extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1056 __THROWNL __nonnull ((1));
1057
1058
1059/* Initialize barrier attribute ATTR. */
1060extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1061 __THROW __nonnull ((1));
1062
1063/* Destroy previously dynamically initialized barrier attribute ATTR. */
1064extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1065 __THROW __nonnull ((1));
1066
1067/* Get the process-shared flag of the barrier attribute ATTR. */
1068extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
1069 __restrict __attr,
1070 int *__restrict __pshared)
1071 __THROW __nonnull ((1, 2));
1072
1073/* Set the process-shared flag of the barrier attribute ATTR. */
1074extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1075 int __pshared)
1076 __THROW __nonnull ((1));
1077#endif
1078
1079
1080/* Functions for handling thread-specific data. */
1081
1082/* Create a key value identifying a location in the thread-specific
1083 data area. Each thread maintains a distinct thread-specific data
1084 area. DESTR_FUNCTION, if non-NULL, is called with the value
1085 associated to that key when the key is destroyed.
1086 DESTR_FUNCTION is not called if the value associated is NULL when
1087 the key is destroyed. */
1088extern int pthread_key_create (pthread_key_t *__key,
1089 void (*__destr_function) (void *))
1090 __THROW __nonnull ((1));
1091
1092/* Destroy KEY. */
1093extern int pthread_key_delete (pthread_key_t __key) __THROW;
1094
1095/* Return current value of the thread-specific data slot identified by KEY. */
1096extern void *pthread_getspecific (pthread_key_t __key) __THROW;
1097
1098/* Store POINTER in the thread-specific data slot identified by KEY. */
1099extern int pthread_setspecific (pthread_key_t __key,
1100 const void *__pointer) __THROW ;
1101
1102
1103#ifdef __USE_XOPEN2K
1104/* Get ID of CPU-time clock for thread THREAD_ID. */
1105extern int pthread_getcpuclockid (pthread_t __thread_id,
1106 __clockid_t *__clock_id)
1107 __THROW __nonnull ((2));
1108#endif
1109
1110
1111/* Install handlers to be called when a new process is created with FORK.
1112 The PREPARE handler is called in the parent process just before performing
1113 FORK. The PARENT handler is called in the parent process just after FORK.
1114 The CHILD handler is called in the child process. Each of the three
1115 handlers can be NULL, meaning that no handler needs to be called at that
1116 point.
1117 PTHREAD_ATFORK can be called several times, in which case the PREPARE
1118 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
1119 first called before FORK), and the PARENT and CHILD handlers are called
1120 in FIFO (first added, first called). */
1121
1122extern int pthread_atfork (void (*__prepare) (void),
1123 void (*__parent) (void),
1124 void (*__child) (void)) __THROW;
1125
1126
1127#ifdef __USE_EXTERN_INLINES
1128/* Optimizations. */
1129__extern_inline int
1130__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
1131{
1132 return __thread1 == __thread2;
1133}
1134#endif
1135
1136__END_DECLS
1137
1138#endif /* pthread.h */
libc/glibc/sysdeps/unix/sysv/linux/hppa/sysdep.h created+509
...@@ -0,0 +1,509 @@
1/* Assembler macros for PA-RISC.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
5 Linux/PA-RISC changes by Philipp Rumpf, <prumpf@tux.org>, March 2000.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library. If not, see
19 <http://www.gnu.org/licenses/>. */
20
21#ifndef _LINUX_HPPA_SYSDEP_H
22#define _LINUX_HPPA_SYSDEP_H 1
23
24#include <sysdeps/unix/sysdep.h>
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <sysdeps/hppa/sysdep.h>
27
28/* Defines RTLD_PRIVATE_ERRNO. */
29#include <dl-sysdep.h>
30
31/* In order to get __set_errno() definition in INLINE_SYSCALL. */
32#ifndef __ASSEMBLER__
33#include <errno.h>
34#endif
35
36#undef ASM_LINE_SEP
37#define ASM_LINE_SEP !
38
39#undef SYS_ify
40#define SYS_ify(syscall_name) (__NR_##syscall_name)
41
42/* The vfork, fork, and clone syscalls clobber r19
43 * and r21. We list r21 as either clobbered or as an
44 * input to a 6-argument syscall. We must save and
45 * restore r19 in both PIC and non-PIC cases.
46 */
47/* WARNING: TREG must be a callee saves register so
48 that it doesn't have to be restored after a call
49 to another function */
50#define TREG 4
51#define SAVE_PIC(SREG) \
52 copy %r19, SREG
53#define LOAD_PIC(LREG) \
54 copy LREG , %r19
55/* Inline assembly defines */
56#define TREG_ASM "%r4" /* Cant clobber r3, it holds framemarker */
57#define SAVE_ASM_PIC " copy %%r19, %" TREG_ASM "\n"
58#define LOAD_ASM_PIC " copy %" TREG_ASM ", %%r19\n"
59#define CLOB_TREG TREG_ASM ,
60#define PIC_REG_DEF register unsigned long __r19 asm("r19");
61#define PIC_REG_USE , "r" (__r19)
62
63#ifdef __ASSEMBLER__
64
65/* Syntactic details of assembler. */
66
67#define ALIGNARG(log2) log2
68
69/* For Linux we can use the system call table in the header file
70 /usr/include/asm/unistd.h
71 of the kernel. But these symbols do not follow the SYS_* syntax
72 so we have to redefine the `SYS_ify' macro here. */
73#undef SYS_ify
74#define SYS_ify(syscall_name) __NR_##syscall_name
75
76/* ELF-like local names start with `.L'. */
77#undef L
78#define L(name) .L##name
79
80/* Linux uses a negative return value to indicate syscall errors,
81 unlike most Unices, which use the condition codes' carry flag.
82
83 Since version 2.1 the return value of a system call might be
84 negative even if the call succeeded. E.g., the `lseek' system call
85 might return a large offset. Therefore we must not anymore test
86 for < 0, but test for a real error by making sure the value in %eax
87 is a real error number. Linus said he will make sure the no syscall
88 returns a value in -1 .. -4095 as a valid result so we can safely
89 test with -4095. */
90
91/* We don't want the label for the error handle to be global when we define
92 it here. */
93/*#ifdef PIC
94# define SYSCALL_ERROR_LABEL 0f
95#else
96# define SYSCALL_ERROR_LABEL syscall_error
97#endif*/
98
99/* Argument manipulation from the stack for preparing to
100 make a syscall */
101
102#define DOARGS_0 /* nothing */
103#define DOARGS_1 /* nothing */
104#define DOARGS_2 /* nothing */
105#define DOARGS_3 /* nothing */
106#define DOARGS_4 /* nothing */
107#define DOARGS_5 ldw -52(%sp), %r22 ASM_LINE_SEP
108#define DOARGS_6 DOARGS_5 ldw -56(%sp), %r21 ASM_LINE_SEP
109
110#define UNDOARGS_0 /* nothing */
111#define UNDOARGS_1 /* nothing */
112#define UNDOARGS_2 /* nothing */
113#define UNDOARGS_3 /* nothing */
114#define UNDOARGS_4 /* nothing */
115#define UNDOARGS_5 /* nothing */
116#define UNDOARGS_6 /* nothing */
117
118/* Define an entry point visible from C.
119
120 There is currently a bug in gdb which prevents us from specifying
121 incomplete stabs information. Fake some entries here which specify
122 the current source file. */
123#undef ENTRY
124#define ENTRY(name) \
125 .text ASM_LINE_SEP \
126 .align ALIGNARG(4) ASM_LINE_SEP \
127 .export C_SYMBOL_NAME(name) ASM_LINE_SEP \
128 .type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
129 cfi_startproc ASM_LINE_SEP \
130 C_LABEL(name) ASM_LINE_SEP \
131 .PROC ASM_LINE_SEP \
132 .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=3 ASM_LINE_SEP \
133 .ENTRY ASM_LINE_SEP \
134 /* SAVE_RP says we do */ ASM_LINE_SEP \
135 stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
136 .cfi_offset 2, -20 ASM_LINE_SEP \
137 /*FIXME: Call mcount? (carefull with stack!) */
138
139/* Some syscall wrappers do not call other functions, and
140 hence are classified as leaf, so add NO_CALLS for gdb */
141#define ENTRY_LEAF(name) \
142 .text ASM_LINE_SEP \
143 .align ALIGNARG(4) ASM_LINE_SEP \
144 .export C_SYMBOL_NAME(name) ASM_LINE_SEP \
145 .type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
146 cfi_startproc ASM_LINE_SEP \
147 C_LABEL(name) ASM_LINE_SEP \
148 .PROC ASM_LINE_SEP \
149 .CALLINFO FRAME=64,NO_CALLS,SAVE_RP,ENTRY_GR=3 ASM_LINE_SEP \
150 .ENTRY ASM_LINE_SEP \
151 /* SAVE_RP says we do */ ASM_LINE_SEP \
152 stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
153 .cfi_offset 2, -20 ASM_LINE_SEP \
154 /*FIXME: Call mcount? (carefull with stack!) */
155
156#undef END
157#define END(name) \
158 .EXIT ASM_LINE_SEP \
159 .PROCEND ASM_LINE_SEP \
160 cfi_endproc ASM_LINE_SEP \
161.size C_SYMBOL_NAME(name), .-C_SYMBOL_NAME(name) ASM_LINE_SEP
162
163/* If compiled for profiling, call `mcount' at the start
164 of each function. No, don't bother. gcc will put the
165 call in for us. */
166#define CALL_MCOUNT /* Do nothing. */
167
168/* syscall wrappers consist of
169 #include <sysdep.h>
170 PSEUDO(...)
171 ret
172 PSEUDO_END(...)
173
174 which means
175 ENTRY(name)
176 DO_CALL(...)
177 bv,n 0(2)
178*/
179
180#undef PSEUDO
181#define PSEUDO(name, syscall_name, args) \
182 ENTRY (name) ASM_LINE_SEP \
183 /* If necc. load args from stack */ ASM_LINE_SEP \
184 DOARGS_##args ASM_LINE_SEP \
185 DO_CALL (syscall_name, args) ASM_LINE_SEP \
186 UNDOARGS_##args ASM_LINE_SEP
187
188#define ret \
189 /* Return value set by ERRNO code */ ASM_LINE_SEP \
190 bv,n 0(2) ASM_LINE_SEP
191
192#undef PSEUDO_END
193#define PSEUDO_END(name) \
194 END (name)
195
196/* We don't set the errno on the return from the syscall */
197#define PSEUDO_NOERRNO(name, syscall_name, args) \
198 ENTRY_LEAF (name) ASM_LINE_SEP \
199 DOARGS_##args ASM_LINE_SEP \
200 DO_CALL_NOERRNO (syscall_name, args) ASM_LINE_SEP \
201 UNDOARGS_##args ASM_LINE_SEP
202
203#define ret_NOERRNO ret
204
205#undef PSEUDO_END_NOERRNO
206#define PSEUDO_END_NOERRNO(name) \
207 END (name)
208
209/* This has to return the error value */
210#undef PSEUDO_ERRVAL
211#define PSEUDO_ERRVAL(name, syscall_name, args) \
212 ENTRY_LEAF (name) ASM_LINE_SEP \
213 DOARGS_##args ASM_LINE_SEP \
214 DO_CALL_ERRVAL (syscall_name, args) ASM_LINE_SEP \
215 UNDOARGS_##args ASM_LINE_SEP
216
217#define ret_ERRVAL ret
218
219#undef PSEUDO_END_ERRVAL
220#define PSEUDO_END_ERRVAL(name) \
221 END(name)
222
223#undef JUMPTARGET
224#define JUMPTARGET(name) name
225#define SYSCALL_PIC_SETUP /* Nothing. */
226
227
228/* FIXME: This comment is not true.
229 * All the syscall assembly macros rely on finding the appropriate
230 SYSCALL_ERROR_LABEL or rather HANDLER. */
231
232/* int * __errno_location(void) so you have to store your value
233 into the return address! */
234#define DEFAULT_SYSCALL_ERROR_HANDLER \
235 .import __errno_location,code ASM_LINE_SEP \
236 /* branch to errno handler */ ASM_LINE_SEP \
237 bl __errno_location,%rp ASM_LINE_SEP
238
239/* Here are the myriad of configuration options that the above can
240 work for... what we've done is provide the framework for future
241 changes if required to each section */
242
243#ifdef PIC
244# if RTLD_PRIVATE_ERRNO
245# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
246# else /* !RTLD_PRIVATE_ERRNO */
247# if defined _LIBC_REENTRANT
248# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
249# else /* !_LIBC_REENTRANT */
250# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
251# endif /* _LIBC_REENTRANT */
252# endif /* RTLD_PRIVATE_ERRNO */
253#else
254# ifndef _LIBC_REENTRANT
255# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
256# else
257# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
258# endif
259#endif
260
261
262/* Linux takes system call arguments in registers:
263 syscall number gr20
264 arg 1 gr26
265 arg 2 gr25
266 arg 3 gr24
267 arg 4 gr23
268 arg 5 gr22
269 arg 6 gr21
270
271 The compiler calls us by the C convention:
272 syscall number in the DO_CALL macro
273 arg 1 gr26
274 arg 2 gr25
275 arg 3 gr24
276 arg 4 gr23
277 arg 5 -52(sp)
278 arg 6 -56(sp)
279
280 gr22 and gr21 are caller-saves, so we can just load the arguments
281 there and generally be happy. */
282
283/* the cmpb...no_error code below inside DO_CALL
284 * is intended to mimic the if (__sys_res...)
285 * code inside INLINE_SYSCALL
286 */
287#define NO_ERROR -0x1000
288
289#undef DO_CALL
290#define DO_CALL(syscall_name, args) \
291 /* Create a frame */ ASM_LINE_SEP \
292 stwm TREG, 64(%sp) ASM_LINE_SEP \
293 .cfi_def_cfa_offset -64 ASM_LINE_SEP \
294 .cfi_offset TREG, 0 ASM_LINE_SEP \
295 stw %sp, -4(%sp) ASM_LINE_SEP \
296 stw %r19, -32(%sp) ASM_LINE_SEP \
297 .cfi_offset 19, 32 ASM_LINE_SEP \
298 /* Save r19 */ ASM_LINE_SEP \
299 SAVE_PIC(TREG) ASM_LINE_SEP \
300 /* Do syscall, delay loads # */ ASM_LINE_SEP \
301 ble 0x100(%sr2,%r0) ASM_LINE_SEP \
302 ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
303 ldi NO_ERROR,%r1 ASM_LINE_SEP \
304 cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
305 /* Restore r19 from TREG */ ASM_LINE_SEP \
306 LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
307 SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
308 /* Use TREG for temp storage */ ASM_LINE_SEP \
309 copy %ret0, TREG /* delay */ ASM_LINE_SEP \
310 /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
311 /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
312 sub %r0, TREG, TREG ASM_LINE_SEP \
313 /* Store into errno location */ ASM_LINE_SEP \
314 stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
315 /* return -1 as error */ ASM_LINE_SEP \
316 ldo -1(%r0), %ret0 ASM_LINE_SEP \
317L(pre_end): ASM_LINE_SEP \
318 /* Restore our frame, restoring TREG */ ASM_LINE_SEP \
319 ldwm -64(%sp), TREG ASM_LINE_SEP \
320 /* Restore return pointer */ ASM_LINE_SEP \
321 ldw -20(%sp),%rp ASM_LINE_SEP
322
323/* We do nothing with the return, except hand it back to someone else */
324#undef DO_CALL_NOERRNO
325#define DO_CALL_NOERRNO(syscall_name, args) \
326 /* No need to store r19 */ ASM_LINE_SEP \
327 ble 0x100(%sr2,%r0) ASM_LINE_SEP \
328 ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
329 /* Caller will restore r19 */ ASM_LINE_SEP
330
331/* Here, we return the ERRVAL in assembly, note we don't call the
332 error handler function, but we do 'negate' the return _IF_
333 it's an error. Not sure if this is the right semantic. */
334
335#undef DO_CALL_ERRVAL
336#define DO_CALL_ERRVAL(syscall_name, args) \
337 /* No need to store r19 */ ASM_LINE_SEP \
338 ble 0x100(%sr2,%r0) ASM_LINE_SEP \
339 ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
340 /* Caller will restore r19 */ ASM_LINE_SEP \
341 ldi NO_ERROR,%r1 ASM_LINE_SEP \
342 cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
343 sub %r0, %ret0, %ret0 ASM_LINE_SEP \
3440: ASM_LINE_SEP
345
346
347#else
348
349/* GCC has to be warned that a syscall may clobber all the ABI
350 registers listed as "caller-saves", see page 8, Table 2
351 in section 2.2.6 of the PA-RISC RUN-TIME architecture
352 document. However! r28 is the result and will conflict with
353 the clobber list so it is left out. Also the input arguments
354 registers r20 -> r26 will conflict with the list so they
355 are treated specially. Although r19 is clobbered by the syscall
356 we cannot say this because it would violate ABI, thus we say
357 TREG is clobbered and use that register to save/restore r19
358 across the syscall. */
359
360#define CALL_CLOB_REGS "%r1", "%r2", CLOB_TREG \
361 "%r20", "%r29", "%r31"
362
363#undef INLINE_SYSCALL
364#define INLINE_SYSCALL(name, nr, args...) \
365({ \
366 long __sys_res = INTERNAL_SYSCALL (name, , nr, args); \
367 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_res, ))) \
368 { \
369 __set_errno (INTERNAL_SYSCALL_ERRNO (__sys_res, )); \
370 __sys_res = -1; \
371 } \
372 __sys_res; \
373})
374
375/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static
376 value to use within the context of the syscall
377 INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise
378 You are allowed to use the syscall result (val) and the DECL error
379 variable to determine what went wrong.
380 INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number.
381 In our case we just flip the sign. */
382
383#undef INTERNAL_SYSCALL_DECL
384#define INTERNAL_SYSCALL_DECL(err)
385
386#undef INTERNAL_SYSCALL_ERROR_P
387#define INTERNAL_SYSCALL_ERROR_P(val, err) \
388 ((val < 0) && (val > -4095))
389
390#undef INTERNAL_SYSCALL_ERRNO
391#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
392
393/* Similar to INLINE_SYSCALL but we don't set errno */
394#undef INTERNAL_SYSCALL
395#define INTERNAL_SYSCALL(name, err, nr, args...) \
396({ \
397 long __sys_res; \
398 { \
399 LOAD_ARGS_##nr(args) \
400 register unsigned long __res asm("r28"); \
401 PIC_REG_DEF \
402 LOAD_REGS_##nr \
403 /* FIXME: HACK save/load r19 around syscall */ \
404 asm volatile( \
405 SAVE_ASM_PIC \
406 " ble 0x100(%%sr2, %%r0)\n" \
407 " ldi %1, %%r20\n" \
408 LOAD_ASM_PIC \
409 : "=r" (__res) \
410 : "i" (SYS_ify(name)) PIC_REG_USE ASM_ARGS_##nr \
411 : "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
412 ); \
413 __sys_res = (long)__res; \
414 } \
415 __sys_res; \
416 })
417
418
419/* The _NCS variant allows non-constant syscall numbers. */
420#undef INTERNAL_SYSCALL_NCS
421#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
422({ \
423 long __sys_res; \
424 { \
425 LOAD_ARGS_##nr(args) \
426 register unsigned long __res asm("r28"); \
427 PIC_REG_DEF \
428 LOAD_REGS_##nr \
429 /* FIXME: HACK save/load r19 around syscall */ \
430 asm volatile( \
431 SAVE_ASM_PIC \
432 " ble 0x100(%%sr2, %%r0)\n" \
433 " copy %1, %%r20\n" \
434 LOAD_ASM_PIC \
435 : "=r" (__res) \
436 : "r" (name) PIC_REG_USE ASM_ARGS_##nr \
437 : "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
438 ); \
439 __sys_res = (long)__res; \
440 } \
441 __sys_res; \
442 })
443
444#define LOAD_ARGS_0()
445#define LOAD_REGS_0
446#define LOAD_ARGS_1(a1) \
447 register unsigned long __x26 = (unsigned long)(a1); \
448 LOAD_ARGS_0()
449#define LOAD_REGS_1 \
450 register unsigned long __r26 __asm__("r26") = __x26; \
451 LOAD_REGS_0
452#define LOAD_ARGS_2(a1,a2) \
453 register unsigned long __x25 = (unsigned long)(a2); \
454 LOAD_ARGS_1(a1)
455#define LOAD_REGS_2 \
456 register unsigned long __r25 __asm__("r25") = __x25; \
457 LOAD_REGS_1
458#define LOAD_ARGS_3(a1,a2,a3) \
459 register unsigned long __x24 = (unsigned long)(a3); \
460 LOAD_ARGS_2(a1,a2)
461#define LOAD_REGS_3 \
462 register unsigned long __r24 __asm__("r24") = __x24; \
463 LOAD_REGS_2
464#define LOAD_ARGS_4(a1,a2,a3,a4) \
465 register unsigned long __x23 = (unsigned long)(a4); \
466 LOAD_ARGS_3(a1,a2,a3)
467#define LOAD_REGS_4 \
468 register unsigned long __r23 __asm__("r23") = __x23; \
469 LOAD_REGS_3
470#define LOAD_ARGS_5(a1,a2,a3,a4,a5) \
471 register unsigned long __x22 = (unsigned long)(a5); \
472 LOAD_ARGS_4(a1,a2,a3,a4)
473#define LOAD_REGS_5 \
474 register unsigned long __r22 __asm__("r22") = __x22; \
475 LOAD_REGS_4
476#define LOAD_ARGS_6(a1,a2,a3,a4,a5,a6) \
477 register unsigned long __x21 = (unsigned long)(a6); \
478 LOAD_ARGS_5(a1,a2,a3,a4,a5)
479#define LOAD_REGS_6 \
480 register unsigned long __r21 __asm__("r21") = __x21; \
481 LOAD_REGS_5
482
483/* Even with zero args we use r20 for the syscall number */
484#define ASM_ARGS_0
485#define ASM_ARGS_1 ASM_ARGS_0, "r" (__r26)
486#define ASM_ARGS_2 ASM_ARGS_1, "r" (__r25)
487#define ASM_ARGS_3 ASM_ARGS_2, "r" (__r24)
488#define ASM_ARGS_4 ASM_ARGS_3, "r" (__r23)
489#define ASM_ARGS_5 ASM_ARGS_4, "r" (__r22)
490#define ASM_ARGS_6 ASM_ARGS_5, "r" (__r21)
491
492/* The registers not listed as inputs but clobbered */
493#define CLOB_ARGS_6
494#define CLOB_ARGS_5 CLOB_ARGS_6, "%r21"
495#define CLOB_ARGS_4 CLOB_ARGS_5, "%r22"
496#define CLOB_ARGS_3 CLOB_ARGS_4, "%r23"
497#define CLOB_ARGS_2 CLOB_ARGS_3, "%r24"
498#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
499#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
500
501#endif /* __ASSEMBLER__ */
502
503/* Pointer mangling is not yet supported for HPPA. */
504#define PTR_MANGLE(var) (void) (var)
505#define PTR_DEMANGLE(var) (void) (var)
506
507#define SINGLE_THREAD_BY_GLOBAL 1
508
509#endif /* _LINUX_HPPA_SYSDEP_H */
libc/glibc/sysdeps/unix/sysv/linux/i386/dl-sysdep.h created+46
...@@ -0,0 +1,46 @@
1/* System-specific settings for dynamic linker code. i386 version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_I386_DL_SYSDEP_H
20
21#include_next <dl-sysdep.h>
22
23/* Traditionally system calls have been made using int $0x80. A
24 second method was introduced which, if possible, will use the
25 sysenter/syscall instructions. To signal the presence and where to
26 find the code the kernel passes an AT_SYSINFO value in the
27 auxiliary vector to the application. */
28#define NEED_DL_SYSINFO 1
29
30#ifndef __ASSEMBLER__
31extern void _dl_sysinfo_int80 (void) attribute_hidden;
32# define DL_SYSINFO_DEFAULT (uintptr_t) _dl_sysinfo_int80
33# define DL_SYSINFO_IMPLEMENTATION \
34 asm (".text\n\t" \
35 ".type _dl_sysinfo_int80,@function\n\t" \
36 ".hidden _dl_sysinfo_int80\n" \
37 CFI_STARTPROC "\n" \
38 "_dl_sysinfo_int80:\n\t" \
39 "int $0x80;\n\t" \
40 "ret;\n\t" \
41 CFI_ENDPROC "\n" \
42 ".size _dl_sysinfo_int80,.-_dl_sysinfo_int80\n\t" \
43 ".previous");
44#endif
45
46#endif /* dl-sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/i386/kernel-features.h created+50
...@@ -0,0 +1,50 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. i386 version.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* Direct socketcalls available with kernel 4.3. */
21#if __LINUX_KERNEL_VERSION >= 0x040300
22# define __ASSUME_SOCKET_SYSCALL 1
23# define __ASSUME_SOCKETPAIR_SYSCALL 1
24# define __ASSUME_BIND_SYSCALL 1
25# define __ASSUME_LISTEN_SYSCALL 1
26# define __ASSUME_GETSOCKOPT_SYSCALL 1
27# define __ASSUME_SETSOCKOPT_SYSCALL 1
28# define __ASSUME_GETSOCKNAME_SYSCALL 1
29# define __ASSUME_GETPEERNAME_SYSCALL 1
30# define __ASSUME_SHUTDOWN_SYSCALL 1
31#endif
32
33#include_next <kernel-features.h>
34
35#undef __ASSUME_ACCEPT_SYSCALL
36
37#if __LINUX_KERNEL_VERSION < 0x040300
38# undef __ASSUME_ACCEPT4_SYSCALL
39# undef __ASSUME_SENDMSG_SYSCALL
40# undef __ASSUME_RECVMSG_SYSCALL
41# undef __ASSUME_CONNECT_SYSCALL
42# undef __ASSUME_RECVFROM_SYSCALL
43# undef __ASSUME_SENDTO_SYSCALL
44#endif
45
46/* i686 only supports ipc syscall. */
47#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
48
49#undef __ASSUME_CLONE_DEFAULT
50#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/i386/sysdep.h created+662
...@@ -0,0 +1,662 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_I386_SYSDEP_H
20#define _LINUX_I386_SYSDEP_H 1
21
22/* Always enable vsyscalls on i386 */
23#define ALWAYS_USE_VSYSCALL 1
24
25/* There is some commonality. */
26#include <sysdeps/unix/sysv/linux/sysdep.h>
27#include <sysdeps/unix/i386/sysdep.h>
28/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
29#include <dl-sysdep.h>
30#include <tls.h>
31
32
33/* For Linux we can use the system call table in the header file
34 /usr/include/asm/unistd.h
35 of the kernel. But these symbols do not follow the SYS_* syntax
36 so we have to redefine the `SYS_ify' macro here. */
37#undef SYS_ify
38#define SYS_ify(syscall_name) __NR_##syscall_name
39
40#ifndef I386_USE_SYSENTER
41# if defined USE_DL_SYSINFO \
42 && (IS_IN (libc) || IS_IN (libpthread))
43# define I386_USE_SYSENTER 1
44# else
45# define I386_USE_SYSENTER 0
46# endif
47#endif
48
49/* Since GCC 5 and above can properly spill %ebx with PIC when needed,
50 we can inline syscalls with 6 arguments if GCC 5 or above is used
51 to compile glibc. Disable GCC 5 optimization when compiling for
52 profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
53 can't be used to put the 6th argument in %ebp for syscall. */
54#if __GNUC_PREREQ (5,0) && !defined PROF && CAN_USE_REGISTER_ASM_EBP
55# define OPTIMIZE_FOR_GCC_5
56#endif
57
58#ifdef __ASSEMBLER__
59
60/* Linux uses a negative return value to indicate syscall errors,
61 unlike most Unices, which use the condition codes' carry flag.
62
63 Since version 2.1 the return value of a system call might be
64 negative even if the call succeeded. E.g., the `lseek' system call
65 might return a large offset. Therefore we must not anymore test
66 for < 0, but test for a real error by making sure the value in %eax
67 is a real error number. Linus said he will make sure the no syscall
68 returns a value in -1 .. -4095 as a valid result so we can savely
69 test with -4095. */
70
71/* We don't want the label for the error handle to be global when we define
72 it here. */
73#define SYSCALL_ERROR_LABEL __syscall_error
74
75#undef PSEUDO
76#define PSEUDO(name, syscall_name, args) \
77 .text; \
78 ENTRY (name) \
79 DO_CALL (syscall_name, args); \
80 cmpl $-4095, %eax; \
81 jae SYSCALL_ERROR_LABEL
82
83#undef PSEUDO_END
84#define PSEUDO_END(name) \
85 SYSCALL_ERROR_HANDLER \
86 END (name)
87
88#undef PSEUDO_NOERRNO
89#define PSEUDO_NOERRNO(name, syscall_name, args) \
90 .text; \
91 ENTRY (name) \
92 DO_CALL (syscall_name, args)
93
94#undef PSEUDO_END_NOERRNO
95#define PSEUDO_END_NOERRNO(name) \
96 END (name)
97
98#define ret_NOERRNO ret
99
100/* The function has to return the error code. */
101#undef PSEUDO_ERRVAL
102#define PSEUDO_ERRVAL(name, syscall_name, args) \
103 .text; \
104 ENTRY (name) \
105 DO_CALL (syscall_name, args); \
106 negl %eax
107
108#undef PSEUDO_END_ERRVAL
109#define PSEUDO_END_ERRVAL(name) \
110 END (name)
111
112#define ret_ERRVAL ret
113
114#define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.c is used. */
115
116/* The original calling convention for system calls on Linux/i386 is
117 to use int $0x80. */
118#if I386_USE_SYSENTER
119# ifdef PIC
120# define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
121# else
122# define ENTER_KERNEL call *_dl_sysinfo
123# endif
124#else
125# define ENTER_KERNEL int $0x80
126#endif
127
128/* Linux takes system call arguments in registers:
129
130 syscall number %eax call-clobbered
131 arg 1 %ebx call-saved
132 arg 2 %ecx call-clobbered
133 arg 3 %edx call-clobbered
134 arg 4 %esi call-saved
135 arg 5 %edi call-saved
136 arg 6 %ebp call-saved
137
138 The stack layout upon entering the function is:
139
140 24(%esp) Arg# 6
141 20(%esp) Arg# 5
142 16(%esp) Arg# 4
143 12(%esp) Arg# 3
144 8(%esp) Arg# 2
145 4(%esp) Arg# 1
146 (%esp) Return address
147
148 (Of course a function with say 3 arguments does not have entries for
149 arguments 4, 5, and 6.)
150
151 The following code tries hard to be optimal. A general assumption
152 (which is true according to the data books I have) is that
153
154 2 * xchg is more expensive than pushl + movl + popl
155
156 Beside this a neat trick is used. The calling conventions for Linux
157 tell that among the registers used for parameters %ecx and %edx need
158 not be saved. Beside this we may clobber this registers even when
159 they are not used for parameter passing.
160
161 As a result one can see below that we save the content of the %ebx
162 register in the %edx register when we have less than 3 arguments
163 (2 * movl is less expensive than pushl + popl).
164
165 Second unlike for the other registers we don't save the content of
166 %ecx and %edx when we have more than 1 and 2 registers resp.
167
168 The code below might look a bit long but we have to take care for
169 the pipelined processors (i586). Here the `pushl' and `popl'
170 instructions are marked as NP (not pairable) but the exception is
171 two consecutive of these instruction. This gives no penalty on
172 other processors though. */
173
174#undef DO_CALL
175#define DO_CALL(syscall_name, args) \
176 PUSHARGS_##args \
177 DOARGS_##args \
178 movl $SYS_ify (syscall_name), %eax; \
179 ENTER_KERNEL \
180 POPARGS_##args
181
182#define PUSHARGS_0 /* No arguments to push. */
183#define DOARGS_0 /* No arguments to frob. */
184#define POPARGS_0 /* No arguments to pop. */
185#define _PUSHARGS_0 /* No arguments to push. */
186#define _DOARGS_0(n) /* No arguments to frob. */
187#define _POPARGS_0 /* No arguments to pop. */
188
189#define PUSHARGS_1 movl %ebx, %edx; L(SAVEBX1): PUSHARGS_0
190#define DOARGS_1 _DOARGS_1 (4)
191#define POPARGS_1 POPARGS_0; movl %edx, %ebx; L(RESTBX1):
192#define _PUSHARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
193 cfi_rel_offset (ebx, 0); L(PUSHBX1): _PUSHARGS_0
194#define _DOARGS_1(n) movl n(%esp), %ebx; _DOARGS_0(n-4)
195#define _POPARGS_1 _POPARGS_0; popl %ebx; cfi_adjust_cfa_offset (-4); \
196 cfi_restore (ebx); L(POPBX1):
197
198#define PUSHARGS_2 PUSHARGS_1
199#define DOARGS_2 _DOARGS_2 (8)
200#define POPARGS_2 POPARGS_1
201#define _PUSHARGS_2 _PUSHARGS_1
202#define _DOARGS_2(n) movl n(%esp), %ecx; _DOARGS_1 (n-4)
203#define _POPARGS_2 _POPARGS_1
204
205#define PUSHARGS_3 _PUSHARGS_2
206#define DOARGS_3 _DOARGS_3 (16)
207#define POPARGS_3 _POPARGS_3
208#define _PUSHARGS_3 _PUSHARGS_2
209#define _DOARGS_3(n) movl n(%esp), %edx; _DOARGS_2 (n-4)
210#define _POPARGS_3 _POPARGS_2
211
212#define PUSHARGS_4 _PUSHARGS_4
213#define DOARGS_4 _DOARGS_4 (24)
214#define POPARGS_4 _POPARGS_4
215#define _PUSHARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
216 cfi_rel_offset (esi, 0); L(PUSHSI1): _PUSHARGS_3
217#define _DOARGS_4(n) movl n(%esp), %esi; _DOARGS_3 (n-4)
218#define _POPARGS_4 _POPARGS_3; popl %esi; cfi_adjust_cfa_offset (-4); \
219 cfi_restore (esi); L(POPSI1):
220
221#define PUSHARGS_5 _PUSHARGS_5
222#define DOARGS_5 _DOARGS_5 (32)
223#define POPARGS_5 _POPARGS_5
224#define _PUSHARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
225 cfi_rel_offset (edi, 0); L(PUSHDI1): _PUSHARGS_4
226#define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4)
227#define _POPARGS_5 _POPARGS_4; popl %edi; cfi_adjust_cfa_offset (-4); \
228 cfi_restore (edi); L(POPDI1):
229
230#define PUSHARGS_6 _PUSHARGS_6
231#define DOARGS_6 _DOARGS_6 (40)
232#define POPARGS_6 _POPARGS_6
233#define _PUSHARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \
234 cfi_rel_offset (ebp, 0); L(PUSHBP1): _PUSHARGS_5
235#define _DOARGS_6(n) movl n(%esp), %ebp; _DOARGS_5 (n-4)
236#define _POPARGS_6 _POPARGS_5; popl %ebp; cfi_adjust_cfa_offset (-4); \
237 cfi_restore (ebp); L(POPBP1):
238
239#else /* !__ASSEMBLER__ */
240
241extern int __syscall_error (int)
242 attribute_hidden __attribute__ ((__regparm__ (1)));
243
244#ifndef OPTIMIZE_FOR_GCC_5
245/* We need some help from the assembler to generate optimal code. We
246 define some macros here which later will be used. */
247asm (".L__X'%ebx = 1\n\t"
248 ".L__X'%ecx = 2\n\t"
249 ".L__X'%edx = 2\n\t"
250 ".L__X'%eax = 3\n\t"
251 ".L__X'%esi = 3\n\t"
252 ".L__X'%edi = 3\n\t"
253 ".L__X'%ebp = 3\n\t"
254 ".L__X'%esp = 3\n\t"
255 ".macro bpushl name reg\n\t"
256 ".if 1 - \\name\n\t"
257 ".if 2 - \\name\n\t"
258 "error\n\t"
259 ".else\n\t"
260 "xchgl \\reg, %ebx\n\t"
261 ".endif\n\t"
262 ".endif\n\t"
263 ".endm\n\t"
264 ".macro bpopl name reg\n\t"
265 ".if 1 - \\name\n\t"
266 ".if 2 - \\name\n\t"
267 "error\n\t"
268 ".else\n\t"
269 "xchgl \\reg, %ebx\n\t"
270 ".endif\n\t"
271 ".endif\n\t"
272 ".endm\n\t");
273
274/* Six-argument syscalls use an out-of-line helper, because an inline
275 asm using all registers apart from %esp cannot work reliably and
276 the assembler does not support describing an asm that saves and
277 restores %ebp itself as a separate stack frame. This structure
278 stores the arguments not passed in registers; %edi is passed with a
279 pointer to this structure. */
280struct libc_do_syscall_args
281{
282 int ebx, edi, ebp;
283};
284#endif
285
286/* Define a macro which expands inline into the wrapper code for a system
287 call. */
288#undef INLINE_SYSCALL
289#if IS_IN (libc)
290# define INLINE_SYSCALL(name, nr, args...) \
291 ({ \
292 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
293 __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )) \
294 ? __syscall_error (-INTERNAL_SYSCALL_ERRNO (resultvar, )) \
295 : (int) resultvar; })
296#else
297# define INLINE_SYSCALL(name, nr, args...) \
298 ({ \
299 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
300 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
301 { \
302 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
303 resultvar = 0xffffffff; \
304 } \
305 (int) resultvar; })
306#endif
307
308/* Set error number and return -1. Return the internal function,
309 __syscall_error, which sets errno from the negative error number
310 and returns -1, to avoid PIC. */
311#undef INLINE_SYSCALL_ERROR_RETURN_VALUE
312#define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \
313 __syscall_error (-(resultvar))
314
315/* List of system calls which are supported as vsyscalls. */
316# define HAVE_CLOCK_GETTIME_VSYSCALL 1
317# define HAVE_GETTIMEOFDAY_VSYSCALL 1
318
319/* Define a macro which expands inline into the wrapper code for a system
320 call. This use is for internal calls that do not need to handle errors
321 normally. It will never touch errno. This returns just what the kernel
322 gave back.
323
324 The _NCS variant allows non-constant syscall numbers but it is not
325 possible to use more than four parameters. */
326#undef INTERNAL_SYSCALL
327#define INTERNAL_SYSCALL_MAIN_0(name, err, args...) \
328 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 0, args)
329#define INTERNAL_SYSCALL_MAIN_1(name, err, args...) \
330 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 1, args)
331#define INTERNAL_SYSCALL_MAIN_2(name, err, args...) \
332 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 2, args)
333#define INTERNAL_SYSCALL_MAIN_3(name, err, args...) \
334 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 3, args)
335#define INTERNAL_SYSCALL_MAIN_4(name, err, args...) \
336 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 4, args)
337#define INTERNAL_SYSCALL_MAIN_5(name, err, args...) \
338 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
339/* Each object using 6-argument inline syscalls must include a
340 definition of __libc_do_syscall. */
341#ifdef OPTIMIZE_FOR_GCC_5
342# define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
343 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
344#else /* GCC 5 */
345# define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3, \
346 arg4, arg5, arg6) \
347 struct libc_do_syscall_args _xv = \
348 { \
349 (int) (arg1), \
350 (int) (arg5), \
351 (int) (arg6) \
352 }; \
353 asm volatile ( \
354 "movl %1, %%eax\n\t" \
355 "call __libc_do_syscall" \
356 : "=a" (resultvar) \
357 : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
358 : "memory", "cc")
359#endif /* GCC 5 */
360#define INTERNAL_SYSCALL(name, err, nr, args...) \
361 ({ \
362 register unsigned int resultvar; \
363 INTERNAL_SYSCALL_MAIN_##nr (name, err, args); \
364 (int) resultvar; })
365#if I386_USE_SYSENTER
366# ifdef OPTIMIZE_FOR_GCC_5
367# ifdef PIC
368# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
369 LOADREGS_##nr(args) \
370 asm volatile ( \
371 "call *%%gs:%P2" \
372 : "=a" (resultvar) \
373 : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
374 ASMARGS_##nr(args) : "memory", "cc")
375# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
376 ({ \
377 register unsigned int resultvar; \
378 LOADREGS_##nr(args) \
379 asm volatile ( \
380 "call *%%gs:%P2" \
381 : "=a" (resultvar) \
382 : "a" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
383 ASMARGS_##nr(args) : "memory", "cc"); \
384 (int) resultvar; })
385# else
386# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
387 LOADREGS_##nr(args) \
388 asm volatile ( \
389 "call *_dl_sysinfo" \
390 : "=a" (resultvar) \
391 : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
392# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
393 ({ \
394 register unsigned int resultvar; \
395 LOADREGS_##nr(args) \
396 asm volatile ( \
397 "call *_dl_sysinfo" \
398 : "=a" (resultvar) \
399 : "a" (name) ASMARGS_##nr(args) : "memory", "cc"); \
400 (int) resultvar; })
401# endif
402# else /* GCC 5 */
403# ifdef PIC
404# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
405 EXTRAVAR_##nr \
406 asm volatile ( \
407 LOADARGS_##nr \
408 "movl %1, %%eax\n\t" \
409 "call *%%gs:%P2\n\t" \
410 RESTOREARGS_##nr \
411 : "=a" (resultvar) \
412 : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
413 ASMFMT_##nr(args) : "memory", "cc")
414# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
415 ({ \
416 register unsigned int resultvar; \
417 EXTRAVAR_##nr \
418 asm volatile ( \
419 LOADARGS_##nr \
420 "call *%%gs:%P2\n\t" \
421 RESTOREARGS_##nr \
422 : "=a" (resultvar) \
423 : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
424 ASMFMT_##nr(args) : "memory", "cc"); \
425 (int) resultvar; })
426# else
427# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
428 EXTRAVAR_##nr \
429 asm volatile ( \
430 LOADARGS_##nr \
431 "movl %1, %%eax\n\t" \
432 "call *_dl_sysinfo\n\t" \
433 RESTOREARGS_##nr \
434 : "=a" (resultvar) \
435 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
436# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
437 ({ \
438 register unsigned int resultvar; \
439 EXTRAVAR_##nr \
440 asm volatile ( \
441 LOADARGS_##nr \
442 "call *_dl_sysinfo\n\t" \
443 RESTOREARGS_##nr \
444 : "=a" (resultvar) \
445 : "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
446 (int) resultvar; })
447# endif
448# endif /* GCC 5 */
449#else
450# ifdef OPTIMIZE_FOR_GCC_5
451# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
452 LOADREGS_##nr(args) \
453 asm volatile ( \
454 "int $0x80" \
455 : "=a" (resultvar) \
456 : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
457# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
458 ({ \
459 register unsigned int resultvar; \
460 LOADREGS_##nr(args) \
461 asm volatile ( \
462 "int $0x80" \
463 : "=a" (resultvar) \
464 : "a" (name) ASMARGS_##nr(args) : "memory", "cc"); \
465 (int) resultvar; })
466# else /* GCC 5 */
467# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
468 EXTRAVAR_##nr \
469 asm volatile ( \
470 LOADARGS_##nr \
471 "movl %1, %%eax\n\t" \
472 "int $0x80\n\t" \
473 RESTOREARGS_##nr \
474 : "=a" (resultvar) \
475 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
476# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
477 ({ \
478 register unsigned int resultvar; \
479 EXTRAVAR_##nr \
480 asm volatile ( \
481 LOADARGS_##nr \
482 "int $0x80\n\t" \
483 RESTOREARGS_##nr \
484 : "=a" (resultvar) \
485 : "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
486 (int) resultvar; })
487# endif /* GCC 5 */
488#endif
489
490#undef INTERNAL_SYSCALL_DECL
491#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
492
493#undef INTERNAL_SYSCALL_ERROR_P
494#define INTERNAL_SYSCALL_ERROR_P(val, err) \
495 ((unsigned int) (val) >= 0xfffff001u)
496
497#undef INTERNAL_SYSCALL_ERRNO
498#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
499
500#define LOADARGS_0
501#ifdef __PIC__
502# if I386_USE_SYSENTER && defined PIC
503# define LOADARGS_1 \
504 "bpushl .L__X'%k3, %k3\n\t"
505# define LOADARGS_5 \
506 "movl %%ebx, %4\n\t" \
507 "movl %3, %%ebx\n\t"
508# else
509# define LOADARGS_1 \
510 "bpushl .L__X'%k2, %k2\n\t"
511# define LOADARGS_5 \
512 "movl %%ebx, %3\n\t" \
513 "movl %2, %%ebx\n\t"
514# endif
515# define LOADARGS_2 LOADARGS_1
516# define LOADARGS_3 \
517 "xchgl %%ebx, %%edi\n\t"
518# define LOADARGS_4 LOADARGS_3
519#else
520# define LOADARGS_1
521# define LOADARGS_2
522# define LOADARGS_3
523# define LOADARGS_4
524# define LOADARGS_5
525#endif
526
527#define RESTOREARGS_0
528#ifdef __PIC__
529# if I386_USE_SYSENTER && defined PIC
530# define RESTOREARGS_1 \
531 "bpopl .L__X'%k3, %k3\n\t"
532# define RESTOREARGS_5 \
533 "movl %4, %%ebx"
534# else
535# define RESTOREARGS_1 \
536 "bpopl .L__X'%k2, %k2\n\t"
537# define RESTOREARGS_5 \
538 "movl %3, %%ebx"
539# endif
540# define RESTOREARGS_2 RESTOREARGS_1
541# define RESTOREARGS_3 \
542 "xchgl %%edi, %%ebx\n\t"
543# define RESTOREARGS_4 RESTOREARGS_3
544#else
545# define RESTOREARGS_1
546# define RESTOREARGS_2
547# define RESTOREARGS_3
548# define RESTOREARGS_4
549# define RESTOREARGS_5
550#endif
551
552#ifdef OPTIMIZE_FOR_GCC_5
553# define LOADREGS_0()
554# define ASMARGS_0()
555# define LOADREGS_1(arg1) \
556 LOADREGS_0 ()
557# define ASMARGS_1(arg1) \
558 ASMARGS_0 (), "b" ((unsigned int) (arg1))
559# define LOADREGS_2(arg1, arg2) \
560 LOADREGS_1 (arg1)
561# define ASMARGS_2(arg1, arg2) \
562 ASMARGS_1 (arg1), "c" ((unsigned int) (arg2))
563# define LOADREGS_3(arg1, arg2, arg3) \
564 LOADREGS_2 (arg1, arg2)
565# define ASMARGS_3(arg1, arg2, arg3) \
566 ASMARGS_2 (arg1, arg2), "d" ((unsigned int) (arg3))
567# define LOADREGS_4(arg1, arg2, arg3, arg4) \
568 LOADREGS_3 (arg1, arg2, arg3)
569# define ASMARGS_4(arg1, arg2, arg3, arg4) \
570 ASMARGS_3 (arg1, arg2, arg3), "S" ((unsigned int) (arg4))
571# define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \
572 LOADREGS_4 (arg1, arg2, arg3, arg4)
573# define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
574 ASMARGS_4 (arg1, arg2, arg3, arg4), "D" ((unsigned int) (arg5))
575# define LOADREGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
576 register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6); \
577 LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
578# define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
579 ASMARGS_5 (arg1, arg2, arg3, arg4, arg5), "r" (_a6)
580#endif /* GCC 5 */
581
582#define ASMFMT_0()
583#ifdef __PIC__
584# define ASMFMT_1(arg1) \
585 , "cd" (arg1)
586# define ASMFMT_2(arg1, arg2) \
587 , "d" (arg1), "c" (arg2)
588# define ASMFMT_3(arg1, arg2, arg3) \
589 , "D" (arg1), "c" (arg2), "d" (arg3)
590# define ASMFMT_4(arg1, arg2, arg3, arg4) \
591 , "D" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
592# define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
593 , "0" (arg1), "m" (_xv), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
594#else
595# define ASMFMT_1(arg1) \
596 , "b" (arg1)
597# define ASMFMT_2(arg1, arg2) \
598 , "b" (arg1), "c" (arg2)
599# define ASMFMT_3(arg1, arg2, arg3) \
600 , "b" (arg1), "c" (arg2), "d" (arg3)
601# define ASMFMT_4(arg1, arg2, arg3, arg4) \
602 , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
603# define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
604 , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
605#endif
606
607#define EXTRAVAR_0
608#define EXTRAVAR_1
609#define EXTRAVAR_2
610#define EXTRAVAR_3
611#define EXTRAVAR_4
612#ifdef __PIC__
613# define EXTRAVAR_5 int _xv;
614#else
615# define EXTRAVAR_5
616#endif
617
618/* Consistency check for position-independent code. */
619#if defined __PIC__ && !defined OPTIMIZE_FOR_GCC_5
620# define check_consistency() \
621 ({ int __res; \
622 __asm__ __volatile__ \
623 (LOAD_PIC_REG_STR (cx) ";" \
624 "subl %%ebx, %%ecx;" \
625 "je 1f;" \
626 "ud2;" \
627 "1:\n" \
628 : "=c" (__res)); \
629 __res; })
630#endif
631
632#endif /* __ASSEMBLER__ */
633
634
635/* Pointer mangling support. */
636#if IS_IN (rtld)
637/* We cannot use the thread descriptor because in ld.so we use setjmp
638 earlier than the descriptor is initialized. Using a global variable
639 is too complicated here since we have no PC-relative addressing mode. */
640#else
641# ifdef __ASSEMBLER__
642# define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \
643 roll $9, reg
644# define PTR_DEMANGLE(reg) rorl $9, reg; \
645 xorl %gs:POINTER_GUARD, reg
646# else
647# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \
648 "roll $9, %0" \
649 : "=r" (var) \
650 : "0" (var), \
651 "i" (offsetof (tcbhead_t, \
652 pointer_guard)))
653# define PTR_DEMANGLE(var) asm ("rorl $9, %0\n" \
654 "xorl %%gs:%c2, %0" \
655 : "=r" (var) \
656 : "0" (var), \
657 "i" (offsetof (tcbhead_t, \
658 pointer_guard)))
659# endif
660#endif
661
662#endif /* linux/i386/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/ia64/asm/break.h created+23
...@@ -0,0 +1,23 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef _ASM_IA64_BREAK_H
3#define _ASM_IA64_BREAK_H
4
5/*
6 * IA-64 Linux break numbers.
7 *
8 * Copyright (C) 1999 Hewlett-Packard Co
9 * Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
10 */
11
12/*
13 * OS-specific debug break numbers:
14 */
15#define __IA64_BREAK_KDB 0x80100
16#define __IA64_BREAK_KPROBE 0x81000 /* .. 0x81fff */
17
18/*
19 * OS-specific break numbers:
20 */
21#define __IA64_BREAK_SYSCALL 0x100000
22
23#endif /* _ASM_IA64_BREAK_H */
libc/glibc/sysdeps/unix/sysv/linux/ia64/asm/unistd.h created+344
...@@ -0,0 +1,344 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * IA-64 Linux syscall numbers and inline-functions.
4 *
5 * Copyright (C) 1998-2005 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */
8#ifndef _UAPI_ASM_IA64_UNISTD_H
9#define _UAPI_ASM_IA64_UNISTD_H
10
11
12#include <asm/break.h>
13
14#define __BREAK_SYSCALL __IA64_BREAK_SYSCALL
15
16#define __NR_ni_syscall 1024
17#define __NR_exit 1025
18#define __NR_read 1026
19#define __NR_write 1027
20#define __NR_open 1028
21#define __NR_close 1029
22#define __NR_creat 1030
23#define __NR_link 1031
24#define __NR_unlink 1032
25#define __NR_execve 1033
26#define __NR_chdir 1034
27#define __NR_fchdir 1035
28#define __NR_utimes 1036
29#define __NR_mknod 1037
30#define __NR_chmod 1038
31#define __NR_chown 1039
32#define __NR_lseek 1040
33#define __NR_getpid 1041
34#define __NR_getppid 1042
35#define __NR_mount 1043
36#define __NR_umount 1044
37#define __NR_setuid 1045
38#define __NR_getuid 1046
39#define __NR_geteuid 1047
40#define __NR_ptrace 1048
41#define __NR_access 1049
42#define __NR_sync 1050
43#define __NR_fsync 1051
44#define __NR_fdatasync 1052
45#define __NR_kill 1053
46#define __NR_rename 1054
47#define __NR_mkdir 1055
48#define __NR_rmdir 1056
49#define __NR_dup 1057
50#define __NR_pipe 1058
51#define __NR_times 1059
52#define __NR_brk 1060
53#define __NR_setgid 1061
54#define __NR_getgid 1062
55#define __NR_getegid 1063
56#define __NR_acct 1064
57#define __NR_ioctl 1065
58#define __NR_fcntl 1066
59#define __NR_umask 1067
60#define __NR_chroot 1068
61#define __NR_ustat 1069
62#define __NR_dup2 1070
63#define __NR_setreuid 1071
64#define __NR_setregid 1072
65#define __NR_getresuid 1073
66#define __NR_setresuid 1074
67#define __NR_getresgid 1075
68#define __NR_setresgid 1076
69#define __NR_getgroups 1077
70#define __NR_setgroups 1078
71#define __NR_getpgid 1079
72#define __NR_setpgid 1080
73#define __NR_setsid 1081
74#define __NR_getsid 1082
75#define __NR_sethostname 1083
76#define __NR_setrlimit 1084
77#define __NR_getrlimit 1085
78#define __NR_getrusage 1086
79#define __NR_gettimeofday 1087
80#define __NR_settimeofday 1088
81#define __NR_select 1089
82#define __NR_poll 1090
83#define __NR_symlink 1091
84#define __NR_readlink 1092
85#define __NR_uselib 1093
86#define __NR_swapon 1094
87#define __NR_swapoff 1095
88#define __NR_reboot 1096
89#define __NR_truncate 1097
90#define __NR_ftruncate 1098
91#define __NR_fchmod 1099
92#define __NR_fchown 1100
93#define __NR_getpriority 1101
94#define __NR_setpriority 1102
95#define __NR_statfs 1103
96#define __NR_fstatfs 1104
97#define __NR_gettid 1105
98#define __NR_semget 1106
99#define __NR_semop 1107
100#define __NR_semctl 1108
101#define __NR_msgget 1109
102#define __NR_msgsnd 1110
103#define __NR_msgrcv 1111
104#define __NR_msgctl 1112
105#define __NR_shmget 1113
106#define __NR_shmat 1114
107#define __NR_shmdt 1115
108#define __NR_shmctl 1116
109/* also known as klogctl() in GNU libc: */
110#define __NR_syslog 1117
111#define __NR_setitimer 1118
112#define __NR_getitimer 1119
113/* 1120 was __NR_old_stat */
114/* 1121 was __NR_old_lstat */
115/* 1122 was __NR_old_fstat */
116#define __NR_vhangup 1123
117#define __NR_lchown 1124
118#define __NR_remap_file_pages 1125
119#define __NR_wait4 1126
120#define __NR_sysinfo 1127
121#define __NR_clone 1128
122#define __NR_setdomainname 1129
123#define __NR_uname 1130
124#define __NR_adjtimex 1131
125/* 1132 was __NR_create_module */
126#define __NR_init_module 1133
127#define __NR_delete_module 1134
128/* 1135 was __NR_get_kernel_syms */
129/* 1136 was __NR_query_module */
130#define __NR_quotactl 1137
131#define __NR_bdflush 1138
132#define __NR_sysfs 1139
133#define __NR_personality 1140
134#define __NR_afs_syscall 1141
135#define __NR_setfsuid 1142
136#define __NR_setfsgid 1143
137#define __NR_getdents 1144
138#define __NR_flock 1145
139#define __NR_readv 1146
140#define __NR_writev 1147
141#define __NR_pread64 1148
142#define __NR_pwrite64 1149
143#define __NR__sysctl 1150
144#define __NR_mmap 1151
145#define __NR_munmap 1152
146#define __NR_mlock 1153
147#define __NR_mlockall 1154
148#define __NR_mprotect 1155
149#define __NR_mremap 1156
150#define __NR_msync 1157
151#define __NR_munlock 1158
152#define __NR_munlockall 1159
153#define __NR_sched_getparam 1160
154#define __NR_sched_setparam 1161
155#define __NR_sched_getscheduler 1162
156#define __NR_sched_setscheduler 1163
157#define __NR_sched_yield 1164
158#define __NR_sched_get_priority_max 1165
159#define __NR_sched_get_priority_min 1166
160#define __NR_sched_rr_get_interval 1167
161#define __NR_nanosleep 1168
162#define __NR_nfsservctl 1169
163#define __NR_prctl 1170
164/* 1171 is reserved for backwards compatibility with old __NR_getpagesize */
165#define __NR_mmap2 1172
166#define __NR_pciconfig_read 1173
167#define __NR_pciconfig_write 1174
168#define __NR_perfmonctl 1175
169#define __NR_sigaltstack 1176
170#define __NR_rt_sigaction 1177
171#define __NR_rt_sigpending 1178
172#define __NR_rt_sigprocmask 1179
173#define __NR_rt_sigqueueinfo 1180
174#define __NR_rt_sigreturn 1181
175#define __NR_rt_sigsuspend 1182
176#define __NR_rt_sigtimedwait 1183
177#define __NR_getcwd 1184
178#define __NR_capget 1185
179#define __NR_capset 1186
180#define __NR_sendfile 1187
181#define __NR_getpmsg 1188
182#define __NR_putpmsg 1189
183#define __NR_socket 1190
184#define __NR_bind 1191
185#define __NR_connect 1192
186#define __NR_listen 1193
187#define __NR_accept 1194
188#define __NR_getsockname 1195
189#define __NR_getpeername 1196
190#define __NR_socketpair 1197
191#define __NR_send 1198
192#define __NR_sendto 1199
193#define __NR_recv 1200
194#define __NR_recvfrom 1201
195#define __NR_shutdown 1202
196#define __NR_setsockopt 1203
197#define __NR_getsockopt 1204
198#define __NR_sendmsg 1205
199#define __NR_recvmsg 1206
200#define __NR_pivot_root 1207
201#define __NR_mincore 1208
202#define __NR_madvise 1209
203#define __NR_stat 1210
204#define __NR_lstat 1211
205#define __NR_fstat 1212
206#define __NR_clone2 1213
207#define __NR_getdents64 1214
208#define __NR_getunwind 1215
209#define __NR_readahead 1216
210#define __NR_setxattr 1217
211#define __NR_lsetxattr 1218
212#define __NR_fsetxattr 1219
213#define __NR_getxattr 1220
214#define __NR_lgetxattr 1221
215#define __NR_fgetxattr 1222
216#define __NR_listxattr 1223
217#define __NR_llistxattr 1224
218#define __NR_flistxattr 1225
219#define __NR_removexattr 1226
220#define __NR_lremovexattr 1227
221#define __NR_fremovexattr 1228
222#define __NR_tkill 1229
223#define __NR_futex 1230
224#define __NR_sched_setaffinity 1231
225#define __NR_sched_getaffinity 1232
226#define __NR_set_tid_address 1233
227#define __NR_fadvise64 1234
228#define __NR_tgkill 1235
229#define __NR_exit_group 1236
230#define __NR_lookup_dcookie 1237
231#define __NR_io_setup 1238
232#define __NR_io_destroy 1239
233#define __NR_io_getevents 1240
234#define __NR_io_submit 1241
235#define __NR_io_cancel 1242
236#define __NR_epoll_create 1243
237#define __NR_epoll_ctl 1244
238#define __NR_epoll_wait 1245
239#define __NR_restart_syscall 1246
240#define __NR_semtimedop 1247
241#define __NR_timer_create 1248
242#define __NR_timer_settime 1249
243#define __NR_timer_gettime 1250
244#define __NR_timer_getoverrun 1251
245#define __NR_timer_delete 1252
246#define __NR_clock_settime 1253
247#define __NR_clock_gettime 1254
248#define __NR_clock_getres 1255
249#define __NR_clock_nanosleep 1256
250#define __NR_fstatfs64 1257
251#define __NR_statfs64 1258
252#define __NR_mbind 1259
253#define __NR_get_mempolicy 1260
254#define __NR_set_mempolicy 1261
255#define __NR_mq_open 1262
256#define __NR_mq_unlink 1263
257#define __NR_mq_timedsend 1264
258#define __NR_mq_timedreceive 1265
259#define __NR_mq_notify 1266
260#define __NR_mq_getsetattr 1267
261#define __NR_kexec_load 1268
262#define __NR_vserver 1269
263#define __NR_waitid 1270
264#define __NR_add_key 1271
265#define __NR_request_key 1272
266#define __NR_keyctl 1273
267#define __NR_ioprio_set 1274
268#define __NR_ioprio_get 1275
269#define __NR_move_pages 1276
270#define __NR_inotify_init 1277
271#define __NR_inotify_add_watch 1278
272#define __NR_inotify_rm_watch 1279
273#define __NR_migrate_pages 1280
274#define __NR_openat 1281
275#define __NR_mkdirat 1282
276#define __NR_mknodat 1283
277#define __NR_fchownat 1284
278#define __NR_futimesat 1285
279#define __NR_newfstatat 1286
280#define __NR_unlinkat 1287
281#define __NR_renameat 1288
282#define __NR_linkat 1289
283#define __NR_symlinkat 1290
284#define __NR_readlinkat 1291
285#define __NR_fchmodat 1292
286#define __NR_faccessat 1293
287#define __NR_pselect6 1294
288#define __NR_ppoll 1295
289#define __NR_unshare 1296
290#define __NR_splice 1297
291#define __NR_set_robust_list 1298
292#define __NR_get_robust_list 1299
293#define __NR_sync_file_range 1300
294#define __NR_tee 1301
295#define __NR_vmsplice 1302
296#define __NR_fallocate 1303
297#define __NR_getcpu 1304
298#define __NR_epoll_pwait 1305
299#define __NR_utimensat 1306
300#define __NR_signalfd 1307
301#define __NR_timerfd 1308
302#define __NR_eventfd 1309
303#define __NR_timerfd_create 1310
304#define __NR_timerfd_settime 1311
305#define __NR_timerfd_gettime 1312
306#define __NR_signalfd4 1313
307#define __NR_eventfd2 1314
308#define __NR_epoll_create1 1315
309#define __NR_dup3 1316
310#define __NR_pipe2 1317
311#define __NR_inotify_init1 1318
312#define __NR_preadv 1319
313#define __NR_pwritev 1320
314#define __NR_rt_tgsigqueueinfo 1321
315#define __NR_recvmmsg 1322
316#define __NR_fanotify_init 1323
317#define __NR_fanotify_mark 1324
318#define __NR_prlimit64 1325
319#define __NR_name_to_handle_at 1326
320#define __NR_open_by_handle_at 1327
321#define __NR_clock_adjtime 1328
322#define __NR_syncfs 1329
323#define __NR_setns 1330
324#define __NR_sendmmsg 1331
325#define __NR_process_vm_readv 1332
326#define __NR_process_vm_writev 1333
327#define __NR_accept4 1334
328#define __NR_finit_module 1335
329#define __NR_sched_setattr 1336
330#define __NR_sched_getattr 1337
331#define __NR_renameat2 1338
332#define __NR_getrandom 1339
333#define __NR_memfd_create 1340
334#define __NR_bpf 1341
335#define __NR_execveat 1342
336#define __NR_userfaultfd 1343
337#define __NR_membarrier 1344
338#define __NR_kcmp 1345
339#define __NR_mlock2 1346
340#define __NR_copy_file_range 1347
341#define __NR_preadv2 1348
342#define __NR_pwritev2 1349
343
344#endif /* _UAPI_ASM_IA64_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/ia64/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* Linux/ia64 is little-endian. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __LITTLE_ENDIAN
libc/glibc/sysdeps/unix/sysv/linux/ia64/bits/stat.h created+149
...@@ -0,0 +1,149 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_KERNEL 0
27#define _STAT_VER_LINUX 1
28#define _STAT_VER _STAT_VER_LINUX
29
30/* Versions of the `xmknod' interface. */
31#define _MKNOD_VER_LINUX 0
32
33struct stat
34 {
35 __dev_t st_dev; /* Device. */
36 __ino_t st_ino; /* File serial number. */
37 __nlink_t st_nlink; /* Link count. */
38 __mode_t st_mode; /* File mode. */
39 __uid_t st_uid; /* User ID of the file's owner. */
40 __gid_t st_gid; /* Group ID of the file's group.*/
41 int __glibc_reserved0;
42 __dev_t st_rdev; /* Device number, if device. */
43 __off_t st_size; /* Size of file, in bytes. */
44#ifdef __USE_XOPEN2K8
45 /* Nanosecond resolution timestamps are stored in a format
46 equivalent to 'struct timespec'. This is the type used
47 whenever possible but the Unix namespace rules do not allow the
48 identifier 'timespec' to appear in the <sys/stat.h> header.
49 Therefore we have to handle the use of this header in strictly
50 standard-compliant sources special. */
51 struct timespec st_atim; /* Time of last access. */
52 struct timespec st_mtim; /* Time of last modification. */
53 struct timespec st_ctim; /* Time of last status change. */
54# define st_atime st_atim.tv_sec /* Backward compatibility. */
55# define st_mtime st_mtim.tv_sec
56# define st_ctime st_ctim.tv_sec
57#else
58 __time_t st_atime; /* Time of last access. */
59 unsigned long int st_atimensec; /* Nscecs of last access. */
60 __time_t st_mtime; /* Time of last modification. */
61 unsigned long int st_mtimensec; /* Nsecs of last modification. */
62 __time_t st_ctime; /* Time of last status change. */
63 unsigned long int st_ctimensec; /* Nsecs of last status change. */
64#endif
65 __blksize_t st_blksize; /* Optimal block size for I/O. */
66 __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
67 long int __glibc_reserved[3];
68 };
69
70#ifdef __USE_LARGEFILE64
71/* Note stat64 is the same shape as stat. */
72struct stat64
73 {
74 __dev_t st_dev; /* Device. */
75 __ino64_t st_ino; /* File serial number. */
76 __nlink_t st_nlink; /* Link count. */
77 __mode_t st_mode; /* File mode. */
78 __uid_t st_uid; /* User ID of the file's owner. */
79 __gid_t st_gid; /* Group ID of the file's group.*/
80 int __glibc_reserved0;
81 __dev_t st_rdev; /* Device number, if device. */
82 __off_t st_size; /* Size of file, in bytes. */
83#ifdef __USE_XOPEN2K8
84 /* Nanosecond resolution timestamps are stored in a format
85 equivalent to 'struct timespec'. This is the type used
86 whenever possible but the Unix namespace rules do not allow the
87 identifier 'timespec' to appear in the <sys/stat.h> header.
88 Therefore we have to handle the use of this header in strictly
89 standard-compliant sources special. */
90 struct timespec st_atim; /* Time of last access. */
91 struct timespec st_mtim; /* Time of last modification. */
92 struct timespec st_ctim; /* Time of last status change. */
93# define st_atime st_atim.tv_sec /* Backward compatibility. */
94# define st_mtime st_mtim.tv_sec
95# define st_ctime st_ctim.tv_sec
96#else
97 __time_t st_atime; /* Time of last access. */
98 unsigned long int st_atimensec; /* Nscecs of last access. */
99 __time_t st_mtime; /* Time of last modification. */
100 unsigned long int st_mtimensec; /* Nsecs of last modification. */
101 __time_t st_ctime; /* Time of last status change. */
102 unsigned long int st_ctimensec; /* Nsecs of last status change. */
103#endif
104 __blksize_t st_blksize; /* Optimal block size for I/O. */
105 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
106 long int __glibc_reserved[3];
107 };
108#endif
109
110/* Tell code we have these members. */
111#define _STATBUF_ST_BLKSIZE
112#define _STATBUF_ST_RDEV
113/* Nanosecond resolution time values are supported. */
114#define _STATBUF_ST_NSEC
115
116/* Encoding of the file mode. */
117
118#define __S_IFMT 0170000 /* These bits determine file type. */
119
120/* File types. */
121#define __S_IFDIR 0040000 /* Directory. */
122#define __S_IFCHR 0020000 /* Character device. */
123#define __S_IFBLK 0060000 /* Block device. */
124#define __S_IFREG 0100000 /* Regular file. */
125#define __S_IFIFO 0010000 /* FIFO. */
126#define __S_IFLNK 0120000 /* Symbolic link. */
127#define __S_IFSOCK 0140000 /* Socket. */
128
129/* POSIX.1b objects. Note that these macros always evaluate to zero. But
130 they do it by enforcing the correct use of the macros. */
131#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
132#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
133#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
134
135/* Protection bits. */
136
137#define __S_ISUID 04000 /* Set user ID on execution. */
138#define __S_ISGID 02000 /* Set group ID on execution. */
139#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
140#define __S_IREAD 0400 /* Read by owner. */
141#define __S_IWRITE 0200 /* Write by owner. */
142#define __S_IEXEC 0100 /* Execute by owner. */
143
144#ifdef __USE_ATFILE
145# define UTIME_NOW ((1l << 30) - 1l)
146# define UTIME_OMIT ((1l << 30) - 2l)
147#endif
148
149#endif /* bits//stat.h */
libc/glibc/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h created+55
...@@ -0,0 +1,55 @@
1/* System-specific settings for dynamic linker code. IA-64 version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_IA64_DL_SYSDEP_H
20#define _LINUX_IA64_DL_SYSDEP_H 1
21
22#include_next <dl-sysdep.h>
23
24/* Traditionally system calls have been made using break 0x100000. A
25 second method was introduced which, if possible, will use the EPC
26 instruction. To signal the presence and where to find the code the
27 kernel passes an AT_SYSINFO_EHDR pointer in the auxiliary vector to
28 the application. */
29#define NEED_DL_SYSINFO 1
30#define USE_DL_SYSINFO 1
31
32#ifndef __ASSEMBLER__
33/* Don't declare this as a function---we want it's entry-point, not
34 it's function descriptor... */
35extern int _dl_sysinfo_break attribute_hidden;
36# define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break)
37# define DL_SYSINFO_IMPLEMENTATION \
38 asm (".text\n\t" \
39 ".hidden _dl_sysinfo_break\n\t" \
40 ".proc _dl_sysinfo_break\n\t" \
41 "_dl_sysinfo_break:\n\t" \
42 ".prologue\n\t" \
43 ".altrp b6\n\t" \
44 ".body\n\t" \
45 "break 0x100000;\n\t" \
46 "br.ret.sptk.many b6;\n\t" \
47 ".endp _dl_sysinfo_break\n\t" \
48 ".previous");
49#endif
50
51/* _dl_argv cannot be attribute_relro, because _dl_start_user
52 might write into it after _dl_start returns. */
53#define DL_ARGV_NOT_RELRO 1
54
55#endif /* dl-sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h created+35
...@@ -0,0 +1,35 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 2010-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _KERNEL_FEATURES_H
21#define _KERNEL_FEATURES_H 1
22
23#include_next <kernel-features.h>
24
25#define __ASSUME_RECV_SYSCALL 1
26#define __ASSUME_SEND_SYSCALL 1
27#define __ASSUME_ACCEPT4_SYSCALL 1
28
29/* No statx system call on ia64 yet. */
30#undef __ASSUME_STATX
31
32#undef __ASSUME_CLONE_DEFAULT
33#define __ASSUME_CLONE2
34
35#endif /* _KERNEL_FEATURES_H */
libc/glibc/sysdeps/unix/sysv/linux/ia64/sysdep.h created+387
...@@ -0,0 +1,387 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
4 Based on code originally written by David Mosberger-Tang
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LINUX_IA64_SYSDEP_H
21#define _LINUX_IA64_SYSDEP_H 1
22
23#include <sysdeps/unix/sysdep.h>
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <sysdeps/ia64/sysdep.h>
26#include <dl-sysdep.h>
27#include <tls.h>
28
29/* In order to get __set_errno() definition in INLINE_SYSCALL. */
30#ifndef __ASSEMBLER__
31#include <errno.h>
32#endif
33
34/* As of GAS v2.4.90.0.7, including a ".align" directive inside a
35 function will cause bad unwind info to be emitted (GAS doesn't know
36 how to account for the padding introduced by the .align directive).
37 Turning on this macro will work around this bug by introducing the
38 necessary padding explicitly. */
39#define GAS_ALIGN_BREAKS_UNWIND_INFO
40
41/* For Linux we can use the system call table in the header file
42 /usr/include/asm/unistd.h
43 of the kernel. But these symbols do not follow the SYS_* syntax
44 so we have to redefine the `SYS_ify' macro here. */
45#undef SYS_ify
46#define SYS_ify(syscall_name) __NR_##syscall_name
47
48/* This is a kludge to make syscalls.list find these under the names
49 pread and pwrite, since some kernel headers define those names
50 and some define the *64 names for the same system calls. */
51#if !defined __NR_pread && defined __NR_pread64
52# define __NR_pread __NR_pread64
53#endif
54#if !defined __NR_pwrite && defined __NR_pwrite64
55# define __NR_pwrite __NR_pwrite64
56#endif
57
58/* This is to help the old kernel headers where __NR_semtimedop is not
59 available. */
60#ifndef __NR_semtimedop
61# define __NR_semtimedop 1247
62#endif
63
64#if defined USE_DL_SYSINFO \
65 && (IS_IN (libc) \
66 || IS_IN (libpthread) || IS_IN (librt))
67# define IA64_USE_NEW_STUB
68#else
69# undef IA64_USE_NEW_STUB
70#endif
71
72#ifdef __ASSEMBLER__
73
74#undef CALL_MCOUNT
75#ifdef PROF
76# define CALL_MCOUNT \
77 .data; \
781: data8 0; /* XXX fixme: use .xdata8 once labels work */ \
79 .previous; \
80 .prologue; \
81 .save ar.pfs, r40; \
82 alloc out0 = ar.pfs, 8, 0, 4, 0; \
83 mov out1 = gp; \
84 .save rp, out2; \
85 mov out2 = rp; \
86 .body; \
87 ;; \
88 addl out3 = @ltoff(1b), gp; \
89 br.call.sptk.many rp = _mcount \
90 ;;
91#else
92# define CALL_MCOUNT /* Do nothing. */
93#endif
94
95/* Linux uses a negative return value to indicate syscall errors, unlike
96 most Unices, which use the condition codes' carry flag.
97
98 Since version 2.1 the return value of a system call might be negative
99 even if the call succeeded. E.g., the `lseek' system call might return
100 a large offset. Therefore we must not anymore test for < 0, but test
101 for a real error by making sure the value in %d0 is a real error
102 number. Linus said he will make sure the no syscall returns a value
103 in -1 .. -4095 as a valid result so we can savely test with -4095. */
104
105/* We don't want the label for the error handler to be visible in the symbol
106 table when we define it here. */
107#define SYSCALL_ERROR_LABEL __syscall_error
108
109#undef PSEUDO
110#define PSEUDO(name, syscall_name, args) \
111 ENTRY(name) \
112 DO_CALL (SYS_ify(syscall_name)); \
113 cmp.eq p6,p0=-1,r10; \
114(p6) br.cond.spnt.few __syscall_error;
115
116#define DO_CALL_VIA_BREAK(num) \
117 mov r15=num; \
118 break __BREAK_SYSCALL
119
120#ifdef IA64_USE_NEW_STUB
121# ifdef SHARED
122# define DO_CALL(num) \
123 .prologue; \
124 adds r2 = SYSINFO_OFFSET, r13;; \
125 ld8 r2 = [r2]; \
126 .save ar.pfs, r11; \
127 mov r11 = ar.pfs;; \
128 .body; \
129 mov r15 = num; \
130 mov b7 = r2; \
131 br.call.sptk.many b6 = b7;; \
132 .restore sp; \
133 mov ar.pfs = r11; \
134 .prologue; \
135 .body
136# else /* !SHARED */
137# define DO_CALL(num) \
138 .prologue; \
139 mov r15 = num; \
140 movl r2 = _dl_sysinfo;; \
141 ld8 r2 = [r2]; \
142 .save ar.pfs, r11; \
143 mov r11 = ar.pfs;; \
144 .body; \
145 mov b7 = r2; \
146 br.call.sptk.many b6 = b7;; \
147 .restore sp; \
148 mov ar.pfs = r11; \
149 .prologue; \
150 .body
151# endif
152#else
153# define DO_CALL(num) DO_CALL_VIA_BREAK(num)
154#endif
155
156#undef PSEUDO_END
157#define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
158
159#undef PSEUDO_NOERRNO
160#define PSEUDO_NOERRNO(name, syscall_name, args) \
161 ENTRY(name) \
162 DO_CALL (SYS_ify(syscall_name));
163
164#undef PSEUDO_END_NOERRNO
165#define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name);
166
167#undef PSEUDO_ERRVAL
168#define PSEUDO_ERRVAL(name, syscall_name, args) \
169 ENTRY(name) \
170 DO_CALL (SYS_ify(syscall_name)); \
171 cmp.eq p6,p0=-1,r10; \
172(p6) mov r10=r8;
173
174
175#undef PSEUDO_END_ERRVAL
176#define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name);
177
178#undef END
179#define END(name) \
180 .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
181 .endp C_SYMBOL_NAME(name)
182
183#define ret br.ret.sptk.few b0
184#define ret_NOERRNO ret
185#define ret_ERRVAL ret
186
187#else /* not __ASSEMBLER__ */
188
189#define BREAK_INSN_1(num) "break " #num ";;\n\t"
190#define BREAK_INSN(num) BREAK_INSN_1(num)
191
192/* On IA-64 we have stacked registers for passing arguments. The
193 "out" registers end up being the called function's "in"
194 registers.
195
196 Also, since we have plenty of registers we have two return values
197 from a syscall. r10 is set to -1 on error, whilst r8 contains the
198 (non-negative) errno on error or the return value on success.
199 */
200
201#ifdef IA64_USE_NEW_STUB
202
203# define DO_INLINE_SYSCALL_NCS(name, nr, args...) \
204 LOAD_ARGS_##nr (args) \
205 register long _r8 __asm ("r8"); \
206 register long _r10 __asm ("r10"); \
207 register long _r15 __asm ("r15") = name; \
208 register void *_b7 __asm ("b7") = ((tcbhead_t *)__thread_self)->__private;\
209 long _retval; \
210 LOAD_REGS_##nr \
211 /* \
212 * Don't specify any unwind info here. We mark ar.pfs as \
213 * clobbered. This will force the compiler to save ar.pfs \
214 * somewhere and emit appropriate unwind info for that save. \
215 */ \
216 __asm __volatile ("br.call.sptk.many b6=%0;;\n" \
217 : "=b"(_b7), "=r" (_r8), "=r" (_r10), "=r" (_r15) \
218 ASM_OUTARGS_##nr \
219 : "0" (_b7), "3" (_r15) ASM_ARGS_##nr \
220 : "memory", "ar.pfs" ASM_CLOBBERS_##nr); \
221 _retval = _r8;
222
223#else /* !IA64_USE_NEW_STUB */
224
225# define DO_INLINE_SYSCALL_NCS(name, nr, args...) \
226 LOAD_ARGS_##nr (args) \
227 register long _r8 asm ("r8"); \
228 register long _r10 asm ("r10"); \
229 register long _r15 asm ("r15") = name; \
230 long _retval; \
231 LOAD_REGS_##nr \
232 __asm __volatile (BREAK_INSN (__BREAK_SYSCALL) \
233 : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
234 ASM_OUTARGS_##nr \
235 : "2" (_r15) ASM_ARGS_##nr \
236 : "memory" ASM_CLOBBERS_##nr); \
237 _retval = _r8;
238
239#endif /* !IA64_USE_NEW_STUB */
240
241#define DO_INLINE_SYSCALL(name, nr, args...) \
242 DO_INLINE_SYSCALL_NCS (__NR_##name, nr, ##args)
243
244#undef INLINE_SYSCALL
245#define INLINE_SYSCALL(name, nr, args...) \
246 ({ \
247 DO_INLINE_SYSCALL_NCS (__NR_##name, nr, args) \
248 if (_r10 == -1) \
249 { \
250 __set_errno (_retval); \
251 _retval = -1; \
252 } \
253 _retval; })
254
255#undef INTERNAL_SYSCALL_DECL
256#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
257
258#undef INTERNAL_SYSCALL
259#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
260 ({ \
261 DO_INLINE_SYSCALL_NCS (name, nr, args) \
262 err = _r10; \
263 _retval; })
264#define INTERNAL_SYSCALL(name, err, nr, args...) \
265 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
266
267#undef INTERNAL_SYSCALL_ERROR_P
268#define INTERNAL_SYSCALL_ERROR_P(val, err) \
269 ({ (void) (val); \
270 (err == -1); \
271 })
272
273#undef INTERNAL_SYSCALL_ERRNO
274#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
275
276#define LOAD_ARGS_0()
277#define LOAD_REGS_0
278#define LOAD_ARGS_1(a1) \
279 long _arg1 = (long) (a1); \
280 LOAD_ARGS_0 ()
281#define LOAD_REGS_1 \
282 register long _out0 asm ("out0") = _arg1; \
283 LOAD_REGS_0
284#define LOAD_ARGS_2(a1, a2) \
285 long _arg2 = (long) (a2); \
286 LOAD_ARGS_1 (a1)
287#define LOAD_REGS_2 \
288 register long _out1 asm ("out1") = _arg2; \
289 LOAD_REGS_1
290#define LOAD_ARGS_3(a1, a2, a3) \
291 long _arg3 = (long) (a3); \
292 LOAD_ARGS_2 (a1, a2)
293#define LOAD_REGS_3 \
294 register long _out2 asm ("out2") = _arg3; \
295 LOAD_REGS_2
296#define LOAD_ARGS_4(a1, a2, a3, a4) \
297 long _arg4 = (long) (a4); \
298 LOAD_ARGS_3 (a1, a2, a3)
299#define LOAD_REGS_4 \
300 register long _out3 asm ("out3") = _arg4; \
301 LOAD_REGS_3
302#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
303 long _arg5 = (long) (a5); \
304 LOAD_ARGS_4 (a1, a2, a3, a4)
305#define LOAD_REGS_5 \
306 register long _out4 asm ("out4") = _arg5; \
307 LOAD_REGS_4
308#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
309 long _arg6 = (long) (a6); \
310 LOAD_ARGS_5 (a1, a2, a3, a4, a5)
311#define LOAD_REGS_6 \
312 register long _out5 asm ("out5") = _arg6; \
313 LOAD_REGS_5
314
315#define ASM_OUTARGS_0
316#define ASM_OUTARGS_1 ASM_OUTARGS_0, "=r" (_out0)
317#define ASM_OUTARGS_2 ASM_OUTARGS_1, "=r" (_out1)
318#define ASM_OUTARGS_3 ASM_OUTARGS_2, "=r" (_out2)
319#define ASM_OUTARGS_4 ASM_OUTARGS_3, "=r" (_out3)
320#define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4)
321#define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5)
322
323#ifdef IA64_USE_NEW_STUB
324#define ASM_ARGS_0
325#define ASM_ARGS_1 ASM_ARGS_0, "4" (_out0)
326#define ASM_ARGS_2 ASM_ARGS_1, "5" (_out1)
327#define ASM_ARGS_3 ASM_ARGS_2, "6" (_out2)
328#define ASM_ARGS_4 ASM_ARGS_3, "7" (_out3)
329#define ASM_ARGS_5 ASM_ARGS_4, "8" (_out4)
330#define ASM_ARGS_6 ASM_ARGS_5, "9" (_out5)
331#else
332#define ASM_ARGS_0
333#define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
334#define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
335#define ASM_ARGS_3 ASM_ARGS_2, "5" (_out2)
336#define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3)
337#define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4)
338#define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5)
339#endif
340
341#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
342#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
343#define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
344#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
345#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
346#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
347#define ASM_CLOBBERS_6_COMMON , "out6", "out7", \
348 /* Non-stacked integer registers, minus r8, r10, r15. */ \
349 "r2", "r3", "r9", "r11", "r13", "r14", "r16", "r17", "r18", \
350 "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
351 "r28", "r29", "r30", "r31", \
352 /* Predicate registers. */ \
353 "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
354 /* Non-rotating fp registers. */ \
355 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
356 /* Branch registers. */ \
357 "b6"
358
359#ifdef IA64_USE_NEW_STUB
360# define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON
361#else
362# define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON , "b7"
363#endif
364
365#endif /* not __ASSEMBLER__ */
366
367/* Pointer mangling support. */
368#if IS_IN (rtld)
369/* We cannot use the thread descriptor because in ld.so we use setjmp
370 earlier than the descriptor is initialized. */
371#else
372# ifdef __ASSEMBLER__
373# define PTR_MANGLE(reg, tmpreg) \
374 add tmpreg=-16,r13 \
375 ;; \
376 ld8 tmpreg=[tmpreg] \
377 ;; \
378 xor reg=reg, tmpreg
379# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
380# else
381# define PTR_MANGLE(var) \
382 (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
383# define PTR_DEMANGLE(var) PTR_MANGLE (var)
384# endif
385#endif
386
387#endif /* linux/ia64/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/include/asm-generic/unistd.h created+791
...@@ -0,0 +1,791 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#include <asm/bitsperlong.h>
3
4/*
5 * This file contains the system call numbers, based on the
6 * layout of the x86-64 architecture, which embeds the
7 * pointer to the syscall in the table.
8 *
9 * As a basic principle, no duplication of functionality
10 * should be added, e.g. we don't use lseek when llseek
11 * is present. New architectures should use this file
12 * and implement the less feature-full calls in user space.
13 */
14
15#ifndef __SYSCALL
16#define __SYSCALL(x, y)
17#endif
18
19#if __BITS_PER_LONG == 32 || defined(__SYSCALL_COMPAT)
20#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32)
21#else
22#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64)
23#endif
24
25#ifdef __SYSCALL_COMPAT
26#define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _comp)
27#define __SC_COMP_3264(_nr, _32, _64, _comp) __SYSCALL(_nr, _comp)
28#else
29#define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
30#define __SC_COMP_3264(_nr, _32, _64, _comp) __SC_3264(_nr, _32, _64)
31#endif
32
33#define __NR_io_setup 0
34__SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
35#define __NR_io_destroy 1
36__SYSCALL(__NR_io_destroy, sys_io_destroy)
37#define __NR_io_submit 2
38__SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit)
39#define __NR_io_cancel 3
40__SYSCALL(__NR_io_cancel, sys_io_cancel)
41#define __NR_io_getevents 4
42__SC_COMP(__NR_io_getevents, sys_io_getevents, compat_sys_io_getevents)
43
44/* fs/xattr.c */
45#define __NR_setxattr 5
46__SYSCALL(__NR_setxattr, sys_setxattr)
47#define __NR_lsetxattr 6
48__SYSCALL(__NR_lsetxattr, sys_lsetxattr)
49#define __NR_fsetxattr 7
50__SYSCALL(__NR_fsetxattr, sys_fsetxattr)
51#define __NR_getxattr 8
52__SYSCALL(__NR_getxattr, sys_getxattr)
53#define __NR_lgetxattr 9
54__SYSCALL(__NR_lgetxattr, sys_lgetxattr)
55#define __NR_fgetxattr 10
56__SYSCALL(__NR_fgetxattr, sys_fgetxattr)
57#define __NR_listxattr 11
58__SYSCALL(__NR_listxattr, sys_listxattr)
59#define __NR_llistxattr 12
60__SYSCALL(__NR_llistxattr, sys_llistxattr)
61#define __NR_flistxattr 13
62__SYSCALL(__NR_flistxattr, sys_flistxattr)
63#define __NR_removexattr 14
64__SYSCALL(__NR_removexattr, sys_removexattr)
65#define __NR_lremovexattr 15
66__SYSCALL(__NR_lremovexattr, sys_lremovexattr)
67#define __NR_fremovexattr 16
68__SYSCALL(__NR_fremovexattr, sys_fremovexattr)
69
70/* fs/dcache.c */
71#define __NR_getcwd 17
72__SYSCALL(__NR_getcwd, sys_getcwd)
73
74/* fs/cookies.c */
75#define __NR_lookup_dcookie 18
76__SC_COMP(__NR_lookup_dcookie, sys_lookup_dcookie, compat_sys_lookup_dcookie)
77
78/* fs/eventfd.c */
79#define __NR_eventfd2 19
80__SYSCALL(__NR_eventfd2, sys_eventfd2)
81
82/* fs/eventpoll.c */
83#define __NR_epoll_create1 20
84__SYSCALL(__NR_epoll_create1, sys_epoll_create1)
85#define __NR_epoll_ctl 21
86__SYSCALL(__NR_epoll_ctl, sys_epoll_ctl)
87#define __NR_epoll_pwait 22
88__SC_COMP(__NR_epoll_pwait, sys_epoll_pwait, compat_sys_epoll_pwait)
89
90/* fs/fcntl.c */
91#define __NR_dup 23
92__SYSCALL(__NR_dup, sys_dup)
93#define __NR_dup3 24
94__SYSCALL(__NR_dup3, sys_dup3)
95#define __NR3264_fcntl 25
96__SC_COMP_3264(__NR3264_fcntl, sys_fcntl64, sys_fcntl, compat_sys_fcntl64)
97
98/* fs/inotify_user.c */
99#define __NR_inotify_init1 26
100__SYSCALL(__NR_inotify_init1, sys_inotify_init1)
101#define __NR_inotify_add_watch 27
102__SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch)
103#define __NR_inotify_rm_watch 28
104__SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
105
106/* fs/ioctl.c */
107#define __NR_ioctl 29
108__SC_COMP(__NR_ioctl, sys_ioctl, compat_sys_ioctl)
109
110/* fs/ioprio.c */
111#define __NR_ioprio_set 30
112__SYSCALL(__NR_ioprio_set, sys_ioprio_set)
113#define __NR_ioprio_get 31
114__SYSCALL(__NR_ioprio_get, sys_ioprio_get)
115
116/* fs/locks.c */
117#define __NR_flock 32
118__SYSCALL(__NR_flock, sys_flock)
119
120/* fs/namei.c */
121#define __NR_mknodat 33
122__SYSCALL(__NR_mknodat, sys_mknodat)
123#define __NR_mkdirat 34
124__SYSCALL(__NR_mkdirat, sys_mkdirat)
125#define __NR_unlinkat 35
126__SYSCALL(__NR_unlinkat, sys_unlinkat)
127#define __NR_symlinkat 36
128__SYSCALL(__NR_symlinkat, sys_symlinkat)
129#define __NR_linkat 37
130__SYSCALL(__NR_linkat, sys_linkat)
131#ifdef __ARCH_WANT_RENAMEAT
132/* renameat is superseded with flags by renameat2 */
133#define __NR_renameat 38
134__SYSCALL(__NR_renameat, sys_renameat)
135#endif /* __ARCH_WANT_RENAMEAT */
136
137/* fs/namespace.c */
138#define __NR_umount2 39
139__SYSCALL(__NR_umount2, sys_umount)
140#define __NR_mount 40
141__SC_COMP(__NR_mount, sys_mount, compat_sys_mount)
142#define __NR_pivot_root 41
143__SYSCALL(__NR_pivot_root, sys_pivot_root)
144
145/* fs/nfsctl.c */
146#define __NR_nfsservctl 42
147__SYSCALL(__NR_nfsservctl, sys_ni_syscall)
148
149/* fs/open.c */
150#define __NR3264_statfs 43
151__SC_COMP_3264(__NR3264_statfs, sys_statfs64, sys_statfs, \
152 compat_sys_statfs64)
153#define __NR3264_fstatfs 44
154__SC_COMP_3264(__NR3264_fstatfs, sys_fstatfs64, sys_fstatfs, \
155 compat_sys_fstatfs64)
156#define __NR3264_truncate 45
157__SC_COMP_3264(__NR3264_truncate, sys_truncate64, sys_truncate, \
158 compat_sys_truncate64)
159#define __NR3264_ftruncate 46
160__SC_COMP_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate, \
161 compat_sys_ftruncate64)
162
163#define __NR_fallocate 47
164__SC_COMP(__NR_fallocate, sys_fallocate, compat_sys_fallocate)
165#define __NR_faccessat 48
166__SYSCALL(__NR_faccessat, sys_faccessat)
167#define __NR_chdir 49
168__SYSCALL(__NR_chdir, sys_chdir)
169#define __NR_fchdir 50
170__SYSCALL(__NR_fchdir, sys_fchdir)
171#define __NR_chroot 51
172__SYSCALL(__NR_chroot, sys_chroot)
173#define __NR_fchmod 52
174__SYSCALL(__NR_fchmod, sys_fchmod)
175#define __NR_fchmodat 53
176__SYSCALL(__NR_fchmodat, sys_fchmodat)
177#define __NR_fchownat 54
178__SYSCALL(__NR_fchownat, sys_fchownat)
179#define __NR_fchown 55
180__SYSCALL(__NR_fchown, sys_fchown)
181#define __NR_openat 56
182__SC_COMP(__NR_openat, sys_openat, compat_sys_openat)
183#define __NR_close 57
184__SYSCALL(__NR_close, sys_close)
185#define __NR_vhangup 58
186__SYSCALL(__NR_vhangup, sys_vhangup)
187
188/* fs/pipe.c */
189#define __NR_pipe2 59
190__SYSCALL(__NR_pipe2, sys_pipe2)
191
192/* fs/quota.c */
193#define __NR_quotactl 60
194__SYSCALL(__NR_quotactl, sys_quotactl)
195
196/* fs/readdir.c */
197#define __NR_getdents64 61
198__SYSCALL(__NR_getdents64, sys_getdents64)
199
200/* fs/read_write.c */
201#define __NR3264_lseek 62
202__SC_3264(__NR3264_lseek, sys_llseek, sys_lseek)
203#define __NR_read 63
204__SYSCALL(__NR_read, sys_read)
205#define __NR_write 64
206__SYSCALL(__NR_write, sys_write)
207#define __NR_readv 65
208__SC_COMP(__NR_readv, sys_readv, compat_sys_readv)
209#define __NR_writev 66
210__SC_COMP(__NR_writev, sys_writev, compat_sys_writev)
211#define __NR_pread64 67
212__SC_COMP(__NR_pread64, sys_pread64, compat_sys_pread64)
213#define __NR_pwrite64 68
214__SC_COMP(__NR_pwrite64, sys_pwrite64, compat_sys_pwrite64)
215#define __NR_preadv 69
216__SC_COMP(__NR_preadv, sys_preadv, compat_sys_preadv)
217#define __NR_pwritev 70
218__SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev)
219
220/* fs/sendfile.c */
221#define __NR3264_sendfile 71
222__SYSCALL(__NR3264_sendfile, sys_sendfile64)
223
224/* fs/select.c */
225#define __NR_pselect6 72
226__SC_COMP(__NR_pselect6, sys_pselect6, compat_sys_pselect6)
227#define __NR_ppoll 73
228__SC_COMP(__NR_ppoll, sys_ppoll, compat_sys_ppoll)
229
230/* fs/signalfd.c */
231#define __NR_signalfd4 74
232__SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4)
233
234/* fs/splice.c */
235#define __NR_vmsplice 75
236__SC_COMP(__NR_vmsplice, sys_vmsplice, compat_sys_vmsplice)
237#define __NR_splice 76
238__SYSCALL(__NR_splice, sys_splice)
239#define __NR_tee 77
240__SYSCALL(__NR_tee, sys_tee)
241
242/* fs/stat.c */
243#define __NR_readlinkat 78
244__SYSCALL(__NR_readlinkat, sys_readlinkat)
245#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
246#define __NR3264_fstatat 79
247__SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat)
248#define __NR3264_fstat 80
249__SC_3264(__NR3264_fstat, sys_fstat64, sys_newfstat)
250#endif
251
252/* fs/sync.c */
253#define __NR_sync 81
254__SYSCALL(__NR_sync, sys_sync)
255#define __NR_fsync 82
256__SYSCALL(__NR_fsync, sys_fsync)
257#define __NR_fdatasync 83
258__SYSCALL(__NR_fdatasync, sys_fdatasync)
259#ifdef __ARCH_WANT_SYNC_FILE_RANGE2
260#define __NR_sync_file_range2 84
261__SC_COMP(__NR_sync_file_range2, sys_sync_file_range2, \
262 compat_sys_sync_file_range2)
263#else
264#define __NR_sync_file_range 84
265__SC_COMP(__NR_sync_file_range, sys_sync_file_range, \
266 compat_sys_sync_file_range)
267#endif
268
269/* fs/timerfd.c */
270#define __NR_timerfd_create 85
271__SYSCALL(__NR_timerfd_create, sys_timerfd_create)
272#define __NR_timerfd_settime 86
273__SC_COMP(__NR_timerfd_settime, sys_timerfd_settime, \
274 compat_sys_timerfd_settime)
275#define __NR_timerfd_gettime 87
276__SC_COMP(__NR_timerfd_gettime, sys_timerfd_gettime, \
277 compat_sys_timerfd_gettime)
278
279/* fs/utimes.c */
280#define __NR_utimensat 88
281__SC_COMP(__NR_utimensat, sys_utimensat, compat_sys_utimensat)
282
283/* kernel/acct.c */
284#define __NR_acct 89
285__SYSCALL(__NR_acct, sys_acct)
286
287/* kernel/capability.c */
288#define __NR_capget 90
289__SYSCALL(__NR_capget, sys_capget)
290#define __NR_capset 91
291__SYSCALL(__NR_capset, sys_capset)
292
293/* kernel/exec_domain.c */
294#define __NR_personality 92
295__SYSCALL(__NR_personality, sys_personality)
296
297/* kernel/exit.c */
298#define __NR_exit 93
299__SYSCALL(__NR_exit, sys_exit)
300#define __NR_exit_group 94
301__SYSCALL(__NR_exit_group, sys_exit_group)
302#define __NR_waitid 95
303__SC_COMP(__NR_waitid, sys_waitid, compat_sys_waitid)
304
305/* kernel/fork.c */
306#define __NR_set_tid_address 96
307__SYSCALL(__NR_set_tid_address, sys_set_tid_address)
308#define __NR_unshare 97
309__SYSCALL(__NR_unshare, sys_unshare)
310
311/* kernel/futex.c */
312#define __NR_futex 98
313__SC_COMP(__NR_futex, sys_futex, compat_sys_futex)
314#define __NR_set_robust_list 99
315__SC_COMP(__NR_set_robust_list, sys_set_robust_list, \
316 compat_sys_set_robust_list)
317#define __NR_get_robust_list 100
318__SC_COMP(__NR_get_robust_list, sys_get_robust_list, \
319 compat_sys_get_robust_list)
320
321/* kernel/hrtimer.c */
322#define __NR_nanosleep 101
323__SC_COMP(__NR_nanosleep, sys_nanosleep, compat_sys_nanosleep)
324
325/* kernel/itimer.c */
326#define __NR_getitimer 102
327__SC_COMP(__NR_getitimer, sys_getitimer, compat_sys_getitimer)
328#define __NR_setitimer 103
329__SC_COMP(__NR_setitimer, sys_setitimer, compat_sys_setitimer)
330
331/* kernel/kexec.c */
332#define __NR_kexec_load 104
333__SC_COMP(__NR_kexec_load, sys_kexec_load, compat_sys_kexec_load)
334
335/* kernel/module.c */
336#define __NR_init_module 105
337__SYSCALL(__NR_init_module, sys_init_module)
338#define __NR_delete_module 106
339__SYSCALL(__NR_delete_module, sys_delete_module)
340
341/* kernel/posix-timers.c */
342#define __NR_timer_create 107
343__SC_COMP(__NR_timer_create, sys_timer_create, compat_sys_timer_create)
344#define __NR_timer_gettime 108
345__SC_COMP(__NR_timer_gettime, sys_timer_gettime, compat_sys_timer_gettime)
346#define __NR_timer_getoverrun 109
347__SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun)
348#define __NR_timer_settime 110
349__SC_COMP(__NR_timer_settime, sys_timer_settime, compat_sys_timer_settime)
350#define __NR_timer_delete 111
351__SYSCALL(__NR_timer_delete, sys_timer_delete)
352#define __NR_clock_settime 112
353__SC_COMP(__NR_clock_settime, sys_clock_settime, compat_sys_clock_settime)
354#define __NR_clock_gettime 113
355__SC_COMP(__NR_clock_gettime, sys_clock_gettime, compat_sys_clock_gettime)
356#define __NR_clock_getres 114
357__SC_COMP(__NR_clock_getres, sys_clock_getres, compat_sys_clock_getres)
358#define __NR_clock_nanosleep 115
359__SC_COMP(__NR_clock_nanosleep, sys_clock_nanosleep, \
360 compat_sys_clock_nanosleep)
361
362/* kernel/printk.c */
363#define __NR_syslog 116
364__SYSCALL(__NR_syslog, sys_syslog)
365
366/* kernel/ptrace.c */
367#define __NR_ptrace 117
368__SYSCALL(__NR_ptrace, sys_ptrace)
369
370/* kernel/sched/core.c */
371#define __NR_sched_setparam 118
372__SYSCALL(__NR_sched_setparam, sys_sched_setparam)
373#define __NR_sched_setscheduler 119
374__SYSCALL(__NR_sched_setscheduler, sys_sched_setscheduler)
375#define __NR_sched_getscheduler 120
376__SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler)
377#define __NR_sched_getparam 121
378__SYSCALL(__NR_sched_getparam, sys_sched_getparam)
379#define __NR_sched_setaffinity 122
380__SC_COMP(__NR_sched_setaffinity, sys_sched_setaffinity, \
381 compat_sys_sched_setaffinity)
382#define __NR_sched_getaffinity 123
383__SC_COMP(__NR_sched_getaffinity, sys_sched_getaffinity, \
384 compat_sys_sched_getaffinity)
385#define __NR_sched_yield 124
386__SYSCALL(__NR_sched_yield, sys_sched_yield)
387#define __NR_sched_get_priority_max 125
388__SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max)
389#define __NR_sched_get_priority_min 126
390__SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min)
391#define __NR_sched_rr_get_interval 127
392__SC_COMP(__NR_sched_rr_get_interval, sys_sched_rr_get_interval, \
393 compat_sys_sched_rr_get_interval)
394
395/* kernel/signal.c */
396#define __NR_restart_syscall 128
397__SYSCALL(__NR_restart_syscall, sys_restart_syscall)
398#define __NR_kill 129
399__SYSCALL(__NR_kill, sys_kill)
400#define __NR_tkill 130
401__SYSCALL(__NR_tkill, sys_tkill)
402#define __NR_tgkill 131
403__SYSCALL(__NR_tgkill, sys_tgkill)
404#define __NR_sigaltstack 132
405__SC_COMP(__NR_sigaltstack, sys_sigaltstack, compat_sys_sigaltstack)
406#define __NR_rt_sigsuspend 133
407__SC_COMP(__NR_rt_sigsuspend, sys_rt_sigsuspend, compat_sys_rt_sigsuspend)
408#define __NR_rt_sigaction 134
409__SC_COMP(__NR_rt_sigaction, sys_rt_sigaction, compat_sys_rt_sigaction)
410#define __NR_rt_sigprocmask 135
411__SC_COMP(__NR_rt_sigprocmask, sys_rt_sigprocmask, compat_sys_rt_sigprocmask)
412#define __NR_rt_sigpending 136
413__SC_COMP(__NR_rt_sigpending, sys_rt_sigpending, compat_sys_rt_sigpending)
414#define __NR_rt_sigtimedwait 137
415__SC_COMP(__NR_rt_sigtimedwait, sys_rt_sigtimedwait, \
416 compat_sys_rt_sigtimedwait)
417#define __NR_rt_sigqueueinfo 138
418__SC_COMP(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo, \
419 compat_sys_rt_sigqueueinfo)
420#define __NR_rt_sigreturn 139
421__SC_COMP(__NR_rt_sigreturn, sys_rt_sigreturn, compat_sys_rt_sigreturn)
422
423/* kernel/sys.c */
424#define __NR_setpriority 140
425__SYSCALL(__NR_setpriority, sys_setpriority)
426#define __NR_getpriority 141
427__SYSCALL(__NR_getpriority, sys_getpriority)
428#define __NR_reboot 142
429__SYSCALL(__NR_reboot, sys_reboot)
430#define __NR_setregid 143
431__SYSCALL(__NR_setregid, sys_setregid)
432#define __NR_setgid 144
433__SYSCALL(__NR_setgid, sys_setgid)
434#define __NR_setreuid 145
435__SYSCALL(__NR_setreuid, sys_setreuid)
436#define __NR_setuid 146
437__SYSCALL(__NR_setuid, sys_setuid)
438#define __NR_setresuid 147
439__SYSCALL(__NR_setresuid, sys_setresuid)
440#define __NR_getresuid 148
441__SYSCALL(__NR_getresuid, sys_getresuid)
442#define __NR_setresgid 149
443__SYSCALL(__NR_setresgid, sys_setresgid)
444#define __NR_getresgid 150
445__SYSCALL(__NR_getresgid, sys_getresgid)
446#define __NR_setfsuid 151
447__SYSCALL(__NR_setfsuid, sys_setfsuid)
448#define __NR_setfsgid 152
449__SYSCALL(__NR_setfsgid, sys_setfsgid)
450#define __NR_times 153
451__SC_COMP(__NR_times, sys_times, compat_sys_times)
452#define __NR_setpgid 154
453__SYSCALL(__NR_setpgid, sys_setpgid)
454#define __NR_getpgid 155
455__SYSCALL(__NR_getpgid, sys_getpgid)
456#define __NR_getsid 156
457__SYSCALL(__NR_getsid, sys_getsid)
458#define __NR_setsid 157
459__SYSCALL(__NR_setsid, sys_setsid)
460#define __NR_getgroups 158
461__SYSCALL(__NR_getgroups, sys_getgroups)
462#define __NR_setgroups 159
463__SYSCALL(__NR_setgroups, sys_setgroups)
464#define __NR_uname 160
465__SYSCALL(__NR_uname, sys_newuname)
466#define __NR_sethostname 161
467__SYSCALL(__NR_sethostname, sys_sethostname)
468#define __NR_setdomainname 162
469__SYSCALL(__NR_setdomainname, sys_setdomainname)
470#define __NR_getrlimit 163
471__SC_COMP(__NR_getrlimit, sys_getrlimit, compat_sys_getrlimit)
472#define __NR_setrlimit 164
473__SC_COMP(__NR_setrlimit, sys_setrlimit, compat_sys_setrlimit)
474#define __NR_getrusage 165
475__SC_COMP(__NR_getrusage, sys_getrusage, compat_sys_getrusage)
476#define __NR_umask 166
477__SYSCALL(__NR_umask, sys_umask)
478#define __NR_prctl 167
479__SYSCALL(__NR_prctl, sys_prctl)
480#define __NR_getcpu 168
481__SYSCALL(__NR_getcpu, sys_getcpu)
482
483/* kernel/time.c */
484#define __NR_gettimeofday 169
485__SC_COMP(__NR_gettimeofday, sys_gettimeofday, compat_sys_gettimeofday)
486#define __NR_settimeofday 170
487__SC_COMP(__NR_settimeofday, sys_settimeofday, compat_sys_settimeofday)
488#define __NR_adjtimex 171
489__SC_COMP(__NR_adjtimex, sys_adjtimex, compat_sys_adjtimex)
490
491/* kernel/timer.c */
492#define __NR_getpid 172
493__SYSCALL(__NR_getpid, sys_getpid)
494#define __NR_getppid 173
495__SYSCALL(__NR_getppid, sys_getppid)
496#define __NR_getuid 174
497__SYSCALL(__NR_getuid, sys_getuid)
498#define __NR_geteuid 175
499__SYSCALL(__NR_geteuid, sys_geteuid)
500#define __NR_getgid 176
501__SYSCALL(__NR_getgid, sys_getgid)
502#define __NR_getegid 177
503__SYSCALL(__NR_getegid, sys_getegid)
504#define __NR_gettid 178
505__SYSCALL(__NR_gettid, sys_gettid)
506#define __NR_sysinfo 179
507__SC_COMP(__NR_sysinfo, sys_sysinfo, compat_sys_sysinfo)
508
509/* ipc/mqueue.c */
510#define __NR_mq_open 180
511__SC_COMP(__NR_mq_open, sys_mq_open, compat_sys_mq_open)
512#define __NR_mq_unlink 181
513__SYSCALL(__NR_mq_unlink, sys_mq_unlink)
514#define __NR_mq_timedsend 182
515__SC_COMP(__NR_mq_timedsend, sys_mq_timedsend, compat_sys_mq_timedsend)
516#define __NR_mq_timedreceive 183
517__SC_COMP(__NR_mq_timedreceive, sys_mq_timedreceive, \
518 compat_sys_mq_timedreceive)
519#define __NR_mq_notify 184
520__SC_COMP(__NR_mq_notify, sys_mq_notify, compat_sys_mq_notify)
521#define __NR_mq_getsetattr 185
522__SC_COMP(__NR_mq_getsetattr, sys_mq_getsetattr, compat_sys_mq_getsetattr)
523
524/* ipc/msg.c */
525#define __NR_msgget 186
526__SYSCALL(__NR_msgget, sys_msgget)
527#define __NR_msgctl 187
528__SC_COMP(__NR_msgctl, sys_msgctl, compat_sys_msgctl)
529#define __NR_msgrcv 188
530__SC_COMP(__NR_msgrcv, sys_msgrcv, compat_sys_msgrcv)
531#define __NR_msgsnd 189
532__SC_COMP(__NR_msgsnd, sys_msgsnd, compat_sys_msgsnd)
533
534/* ipc/sem.c */
535#define __NR_semget 190
536__SYSCALL(__NR_semget, sys_semget)
537#define __NR_semctl 191
538__SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)
539#define __NR_semtimedop 192
540__SC_COMP(__NR_semtimedop, sys_semtimedop, compat_sys_semtimedop)
541#define __NR_semop 193
542__SYSCALL(__NR_semop, sys_semop)
543
544/* ipc/shm.c */
545#define __NR_shmget 194
546__SYSCALL(__NR_shmget, sys_shmget)
547#define __NR_shmctl 195
548__SC_COMP(__NR_shmctl, sys_shmctl, compat_sys_shmctl)
549#define __NR_shmat 196
550__SC_COMP(__NR_shmat, sys_shmat, compat_sys_shmat)
551#define __NR_shmdt 197
552__SYSCALL(__NR_shmdt, sys_shmdt)
553
554/* net/socket.c */
555#define __NR_socket 198
556__SYSCALL(__NR_socket, sys_socket)
557#define __NR_socketpair 199
558__SYSCALL(__NR_socketpair, sys_socketpair)
559#define __NR_bind 200
560__SYSCALL(__NR_bind, sys_bind)
561#define __NR_listen 201
562__SYSCALL(__NR_listen, sys_listen)
563#define __NR_accept 202
564__SYSCALL(__NR_accept, sys_accept)
565#define __NR_connect 203
566__SYSCALL(__NR_connect, sys_connect)
567#define __NR_getsockname 204
568__SYSCALL(__NR_getsockname, sys_getsockname)
569#define __NR_getpeername 205
570__SYSCALL(__NR_getpeername, sys_getpeername)
571#define __NR_sendto 206
572__SYSCALL(__NR_sendto, sys_sendto)
573#define __NR_recvfrom 207
574__SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom)
575#define __NR_setsockopt 208
576__SC_COMP(__NR_setsockopt, sys_setsockopt, compat_sys_setsockopt)
577#define __NR_getsockopt 209
578__SC_COMP(__NR_getsockopt, sys_getsockopt, compat_sys_getsockopt)
579#define __NR_shutdown 210
580__SYSCALL(__NR_shutdown, sys_shutdown)
581#define __NR_sendmsg 211
582__SC_COMP(__NR_sendmsg, sys_sendmsg, compat_sys_sendmsg)
583#define __NR_recvmsg 212
584__SC_COMP(__NR_recvmsg, sys_recvmsg, compat_sys_recvmsg)
585
586/* mm/filemap.c */
587#define __NR_readahead 213
588__SC_COMP(__NR_readahead, sys_readahead, compat_sys_readahead)
589
590/* mm/nommu.c, also with MMU */
591#define __NR_brk 214
592__SYSCALL(__NR_brk, sys_brk)
593#define __NR_munmap 215
594__SYSCALL(__NR_munmap, sys_munmap)
595#define __NR_mremap 216
596__SYSCALL(__NR_mremap, sys_mremap)
597
598/* security/keys/keyctl.c */
599#define __NR_add_key 217
600__SYSCALL(__NR_add_key, sys_add_key)
601#define __NR_request_key 218
602__SYSCALL(__NR_request_key, sys_request_key)
603#define __NR_keyctl 219
604__SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl)
605
606/* arch/example/kernel/sys_example.c */
607#define __NR_clone 220
608__SYSCALL(__NR_clone, sys_clone)
609#define __NR_execve 221
610__SC_COMP(__NR_execve, sys_execve, compat_sys_execve)
611
612#define __NR3264_mmap 222
613__SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap)
614/* mm/fadvise.c */
615#define __NR3264_fadvise64 223
616__SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64)
617
618/* mm/, CONFIG_MMU only */
619#ifndef __ARCH_NOMMU
620#define __NR_swapon 224
621__SYSCALL(__NR_swapon, sys_swapon)
622#define __NR_swapoff 225
623__SYSCALL(__NR_swapoff, sys_swapoff)
624#define __NR_mprotect 226
625__SYSCALL(__NR_mprotect, sys_mprotect)
626#define __NR_msync 227
627__SYSCALL(__NR_msync, sys_msync)
628#define __NR_mlock 228
629__SYSCALL(__NR_mlock, sys_mlock)
630#define __NR_munlock 229
631__SYSCALL(__NR_munlock, sys_munlock)
632#define __NR_mlockall 230
633__SYSCALL(__NR_mlockall, sys_mlockall)
634#define __NR_munlockall 231
635__SYSCALL(__NR_munlockall, sys_munlockall)
636#define __NR_mincore 232
637__SYSCALL(__NR_mincore, sys_mincore)
638#define __NR_madvise 233
639__SYSCALL(__NR_madvise, sys_madvise)
640#define __NR_remap_file_pages 234
641__SYSCALL(__NR_remap_file_pages, sys_remap_file_pages)
642#define __NR_mbind 235
643__SC_COMP(__NR_mbind, sys_mbind, compat_sys_mbind)
644#define __NR_get_mempolicy 236
645__SC_COMP(__NR_get_mempolicy, sys_get_mempolicy, compat_sys_get_mempolicy)
646#define __NR_set_mempolicy 237
647__SC_COMP(__NR_set_mempolicy, sys_set_mempolicy, compat_sys_set_mempolicy)
648#define __NR_migrate_pages 238
649__SC_COMP(__NR_migrate_pages, sys_migrate_pages, compat_sys_migrate_pages)
650#define __NR_move_pages 239
651__SC_COMP(__NR_move_pages, sys_move_pages, compat_sys_move_pages)
652#endif
653
654#define __NR_rt_tgsigqueueinfo 240
655__SC_COMP(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, \
656 compat_sys_rt_tgsigqueueinfo)
657#define __NR_perf_event_open 241
658__SYSCALL(__NR_perf_event_open, sys_perf_event_open)
659#define __NR_accept4 242
660__SYSCALL(__NR_accept4, sys_accept4)
661#define __NR_recvmmsg 243
662__SC_COMP(__NR_recvmmsg, sys_recvmmsg, compat_sys_recvmmsg)
663
664/*
665 * Architectures may provide up to 16 syscalls of their own
666 * starting with this value.
667 */
668#define __NR_arch_specific_syscall 244
669
670#define __NR_wait4 260
671__SC_COMP(__NR_wait4, sys_wait4, compat_sys_wait4)
672#define __NR_prlimit64 261
673__SYSCALL(__NR_prlimit64, sys_prlimit64)
674#define __NR_fanotify_init 262
675__SYSCALL(__NR_fanotify_init, sys_fanotify_init)
676#define __NR_fanotify_mark 263
677__SYSCALL(__NR_fanotify_mark, sys_fanotify_mark)
678#define __NR_name_to_handle_at 264
679__SYSCALL(__NR_name_to_handle_at, sys_name_to_handle_at)
680#define __NR_open_by_handle_at 265
681__SC_COMP(__NR_open_by_handle_at, sys_open_by_handle_at, \
682 compat_sys_open_by_handle_at)
683#define __NR_clock_adjtime 266
684__SC_COMP(__NR_clock_adjtime, sys_clock_adjtime, compat_sys_clock_adjtime)
685#define __NR_syncfs 267
686__SYSCALL(__NR_syncfs, sys_syncfs)
687#define __NR_setns 268
688__SYSCALL(__NR_setns, sys_setns)
689#define __NR_sendmmsg 269
690__SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg)
691#define __NR_process_vm_readv 270
692__SC_COMP(__NR_process_vm_readv, sys_process_vm_readv, \
693 compat_sys_process_vm_readv)
694#define __NR_process_vm_writev 271
695__SC_COMP(__NR_process_vm_writev, sys_process_vm_writev, \
696 compat_sys_process_vm_writev)
697#define __NR_kcmp 272
698__SYSCALL(__NR_kcmp, sys_kcmp)
699#define __NR_finit_module 273
700__SYSCALL(__NR_finit_module, sys_finit_module)
701#define __NR_sched_setattr 274
702__SYSCALL(__NR_sched_setattr, sys_sched_setattr)
703#define __NR_sched_getattr 275
704__SYSCALL(__NR_sched_getattr, sys_sched_getattr)
705#define __NR_renameat2 276
706__SYSCALL(__NR_renameat2, sys_renameat2)
707#define __NR_seccomp 277
708__SYSCALL(__NR_seccomp, sys_seccomp)
709#define __NR_getrandom 278
710__SYSCALL(__NR_getrandom, sys_getrandom)
711#define __NR_memfd_create 279
712__SYSCALL(__NR_memfd_create, sys_memfd_create)
713#define __NR_bpf 280
714__SYSCALL(__NR_bpf, sys_bpf)
715#define __NR_execveat 281
716__SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat)
717#define __NR_userfaultfd 282
718__SYSCALL(__NR_userfaultfd, sys_userfaultfd)
719#define __NR_membarrier 283
720__SYSCALL(__NR_membarrier, sys_membarrier)
721#define __NR_mlock2 284
722__SYSCALL(__NR_mlock2, sys_mlock2)
723#define __NR_copy_file_range 285
724__SYSCALL(__NR_copy_file_range, sys_copy_file_range)
725#define __NR_preadv2 286
726__SC_COMP(__NR_preadv2, sys_preadv2, compat_sys_preadv2)
727#define __NR_pwritev2 287
728__SC_COMP(__NR_pwritev2, sys_pwritev2, compat_sys_pwritev2)
729#define __NR_pkey_mprotect 288
730__SYSCALL(__NR_pkey_mprotect, sys_pkey_mprotect)
731#define __NR_pkey_alloc 289
732__SYSCALL(__NR_pkey_alloc, sys_pkey_alloc)
733#define __NR_pkey_free 290
734__SYSCALL(__NR_pkey_free, sys_pkey_free)
735#define __NR_statx 291
736__SYSCALL(__NR_statx, sys_statx)
737#define __NR_io_pgetevents 292
738__SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents)
739#define __NR_rseq 293
740__SYSCALL(__NR_rseq, sys_rseq)
741
742#undef __NR_syscalls
743#define __NR_syscalls 294
744
745/*
746 * 32 bit systems traditionally used different
747 * syscalls for off_t and loff_t arguments, while
748 * 64 bit systems only need the off_t version.
749 * For new 32 bit platforms, there is no need to
750 * implement the old 32 bit off_t syscalls, so
751 * they take different names.
752 * Here we map the numbers so that both versions
753 * use the same syscall table layout.
754 */
755#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
756#define __NR_fcntl __NR3264_fcntl
757#define __NR_statfs __NR3264_statfs
758#define __NR_fstatfs __NR3264_fstatfs
759#define __NR_truncate __NR3264_truncate
760#define __NR_ftruncate __NR3264_ftruncate
761#define __NR_lseek __NR3264_lseek
762#define __NR_sendfile __NR3264_sendfile
763#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
764#define __NR_newfstatat __NR3264_fstatat
765#define __NR_fstat __NR3264_fstat
766#endif
767#define __NR_mmap __NR3264_mmap
768#define __NR_fadvise64 __NR3264_fadvise64
769#ifdef __NR3264_stat
770#define __NR_stat __NR3264_stat
771#define __NR_lstat __NR3264_lstat
772#endif
773#else
774#define __NR_fcntl64 __NR3264_fcntl
775#define __NR_statfs64 __NR3264_statfs
776#define __NR_fstatfs64 __NR3264_fstatfs
777#define __NR_truncate64 __NR3264_truncate
778#define __NR_ftruncate64 __NR3264_ftruncate
779#define __NR_llseek __NR3264_lseek
780#define __NR_sendfile64 __NR3264_sendfile
781#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
782#define __NR_fstatat64 __NR3264_fstatat
783#define __NR_fstat64 __NR3264_fstat
784#endif
785#define __NR_mmap2 __NR3264_mmap
786#define __NR_fadvise64_64 __NR3264_fadvise64
787#ifdef __NR3264_stat
788#define __NR_stat64 __NR3264_stat
789#define __NR_lstat64 __NR3264_lstat
790#endif
791#endif
libc/glibc/sysdeps/unix/sysv/linux/include/asm/unistd_32.h created+401
...@@ -0,0 +1,401 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef __ASM_SH_UNISTD_32_H
3#define __ASM_SH_UNISTD_32_H
4
5/*
6 * Copyright (C) 1999 Niibe Yutaka
7 */
8
9/*
10 * This file contains the system call numbers.
11 */
12
13#define __NR_restart_syscall 0
14#define __NR_exit 1
15#define __NR_fork 2
16#define __NR_read 3
17#define __NR_write 4
18#define __NR_open 5
19#define __NR_close 6
20#define __NR_waitpid 7
21#define __NR_creat 8
22#define __NR_link 9
23#define __NR_unlink 10
24#define __NR_execve 11
25#define __NR_chdir 12
26#define __NR_time 13
27#define __NR_mknod 14
28#define __NR_chmod 15
29#define __NR_lchown 16
30 /* 17 was sys_break */
31#define __NR_oldstat 18
32#define __NR_lseek 19
33#define __NR_getpid 20
34#define __NR_mount 21
35#define __NR_umount 22
36#define __NR_setuid 23
37#define __NR_getuid 24
38#define __NR_stime 25
39#define __NR_ptrace 26
40#define __NR_alarm 27
41#define __NR_oldfstat 28
42#define __NR_pause 29
43#define __NR_utime 30
44 /* 31 was sys_stty */
45 /* 32 was sys_gtty */
46#define __NR_access 33
47#define __NR_nice 34
48 /* 35 was sys_ftime */
49#define __NR_sync 36
50#define __NR_kill 37
51#define __NR_rename 38
52#define __NR_mkdir 39
53#define __NR_rmdir 40
54#define __NR_dup 41
55#define __NR_pipe 42
56#define __NR_times 43
57 /* 44 was sys_prof */
58#define __NR_brk 45
59#define __NR_setgid 46
60#define __NR_getgid 47
61#define __NR_signal 48
62#define __NR_geteuid 49
63#define __NR_getegid 50
64#define __NR_acct 51
65#define __NR_umount2 52
66 /* 53 was sys_lock */
67#define __NR_ioctl 54
68#define __NR_fcntl 55
69 /* 56 was sys_mpx */
70#define __NR_setpgid 57
71 /* 58 was sys_ulimit */
72 /* 59 was sys_olduname */
73#define __NR_umask 60
74#define __NR_chroot 61
75#define __NR_ustat 62
76#define __NR_dup2 63
77#define __NR_getppid 64
78#define __NR_getpgrp 65
79#define __NR_setsid 66
80#define __NR_sigaction 67
81#define __NR_sgetmask 68
82#define __NR_ssetmask 69
83#define __NR_setreuid 70
84#define __NR_setregid 71
85#define __NR_sigsuspend 72
86#define __NR_sigpending 73
87#define __NR_sethostname 74
88#define __NR_setrlimit 75
89#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
90#define __NR_getrusage 77
91#define __NR_gettimeofday 78
92#define __NR_settimeofday 79
93#define __NR_getgroups 80
94#define __NR_setgroups 81
95 /* 82 was sys_oldselect */
96#define __NR_symlink 83
97#define __NR_oldlstat 84
98#define __NR_readlink 85
99#define __NR_uselib 86
100#define __NR_swapon 87
101#define __NR_reboot 88
102#define __NR_readdir 89
103#define __NR_mmap 90
104#define __NR_munmap 91
105#define __NR_truncate 92
106#define __NR_ftruncate 93
107#define __NR_fchmod 94
108#define __NR_fchown 95
109#define __NR_getpriority 96
110#define __NR_setpriority 97
111 /* 98 was sys_profil */
112#define __NR_statfs 99
113#define __NR_fstatfs 100
114 /* 101 was sys_ioperm */
115#define __NR_socketcall 102
116#define __NR_syslog 103
117#define __NR_setitimer 104
118#define __NR_getitimer 105
119#define __NR_stat 106
120#define __NR_lstat 107
121#define __NR_fstat 108
122#define __NR_olduname 109
123 /* 110 was sys_iopl */
124#define __NR_vhangup 111
125 /* 112 was sys_idle */
126 /* 113 was sys_vm86old */
127#define __NR_wait4 114
128#define __NR_swapoff 115
129#define __NR_sysinfo 116
130#define __NR_ipc 117
131#define __NR_fsync 118
132#define __NR_sigreturn 119
133#define __NR_clone 120
134#define __NR_setdomainname 121
135#define __NR_uname 122
136#define __NR_cacheflush 123
137#define __NR_adjtimex 124
138#define __NR_mprotect 125
139#define __NR_sigprocmask 126
140 /* 127 was sys_create_module */
141#define __NR_init_module 128
142#define __NR_delete_module 129
143 /* 130 was sys_get_kernel_syms */
144#define __NR_quotactl 131
145#define __NR_getpgid 132
146#define __NR_fchdir 133
147#define __NR_bdflush 134
148#define __NR_sysfs 135
149#define __NR_personality 136
150 /* 137 was sys_afs_syscall */
151#define __NR_setfsuid 138
152#define __NR_setfsgid 139
153#define __NR__llseek 140
154#define __NR_getdents 141
155#define __NR__newselect 142
156#define __NR_flock 143
157#define __NR_msync 144
158#define __NR_readv 145
159#define __NR_writev 146
160#define __NR_getsid 147
161#define __NR_fdatasync 148
162#define __NR__sysctl 149
163#define __NR_mlock 150
164#define __NR_munlock 151
165#define __NR_mlockall 152
166#define __NR_munlockall 153
167#define __NR_sched_setparam 154
168#define __NR_sched_getparam 155
169#define __NR_sched_setscheduler 156
170#define __NR_sched_getscheduler 157
171#define __NR_sched_yield 158
172#define __NR_sched_get_priority_max 159
173#define __NR_sched_get_priority_min 160
174#define __NR_sched_rr_get_interval 161
175#define __NR_nanosleep 162
176#define __NR_mremap 163
177#define __NR_setresuid 164
178#define __NR_getresuid 165
179 /* 166 was sys_vm86 */
180 /* 167 was sys_query_module */
181#define __NR_poll 168
182#define __NR_nfsservctl 169
183#define __NR_setresgid 170
184#define __NR_getresgid 171
185#define __NR_prctl 172
186#define __NR_rt_sigreturn 173
187#define __NR_rt_sigaction 174
188#define __NR_rt_sigprocmask 175
189#define __NR_rt_sigpending 176
190#define __NR_rt_sigtimedwait 177
191#define __NR_rt_sigqueueinfo 178
192#define __NR_rt_sigsuspend 179
193#define __NR_pread64 180
194#define __NR_pwrite64 181
195#define __NR_chown 182
196#define __NR_getcwd 183
197#define __NR_capget 184
198#define __NR_capset 185
199#define __NR_sigaltstack 186
200#define __NR_sendfile 187
201 /* 188 reserved for sys_getpmsg */
202 /* 189 reserved for sys_putpmsg */
203#define __NR_vfork 190
204#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
205#define __NR_mmap2 192
206#define __NR_truncate64 193
207#define __NR_ftruncate64 194
208#define __NR_stat64 195
209#define __NR_lstat64 196
210#define __NR_fstat64 197
211#define __NR_lchown32 198
212#define __NR_getuid32 199
213#define __NR_getgid32 200
214#define __NR_geteuid32 201
215#define __NR_getegid32 202
216#define __NR_setreuid32 203
217#define __NR_setregid32 204
218#define __NR_getgroups32 205
219#define __NR_setgroups32 206
220#define __NR_fchown32 207
221#define __NR_setresuid32 208
222#define __NR_getresuid32 209
223#define __NR_setresgid32 210
224#define __NR_getresgid32 211
225#define __NR_chown32 212
226#define __NR_setuid32 213
227#define __NR_setgid32 214
228#define __NR_setfsuid32 215
229#define __NR_setfsgid32 216
230#define __NR_pivot_root 217
231#define __NR_mincore 218
232#define __NR_madvise 219
233#define __NR_getdents64 220
234#define __NR_fcntl64 221
235 /* 222 is reserved for tux */
236 /* 223 is unused */
237#define __NR_gettid 224
238#define __NR_readahead 225
239#define __NR_setxattr 226
240#define __NR_lsetxattr 227
241#define __NR_fsetxattr 228
242#define __NR_getxattr 229
243#define __NR_lgetxattr 230
244#define __NR_fgetxattr 231
245#define __NR_listxattr 232
246#define __NR_llistxattr 233
247#define __NR_flistxattr 234
248#define __NR_removexattr 235
249#define __NR_lremovexattr 236
250#define __NR_fremovexattr 237
251#define __NR_tkill 238
252#define __NR_sendfile64 239
253#define __NR_futex 240
254#define __NR_sched_setaffinity 241
255#define __NR_sched_getaffinity 242
256 /* 243 is reserved for set_thread_area */
257 /* 244 is reserved for get_thread_area */
258#define __NR_io_setup 245
259#define __NR_io_destroy 246
260#define __NR_io_getevents 247
261#define __NR_io_submit 248
262#define __NR_io_cancel 249
263#define __NR_fadvise64 250
264 /* 251 is unused */
265#define __NR_exit_group 252
266#define __NR_lookup_dcookie 253
267#define __NR_epoll_create 254
268#define __NR_epoll_ctl 255
269#define __NR_epoll_wait 256
270#define __NR_remap_file_pages 257
271#define __NR_set_tid_address 258
272#define __NR_timer_create 259
273#define __NR_timer_settime (__NR_timer_create+1)
274#define __NR_timer_gettime (__NR_timer_create+2)
275#define __NR_timer_getoverrun (__NR_timer_create+3)
276#define __NR_timer_delete (__NR_timer_create+4)
277#define __NR_clock_settime (__NR_timer_create+5)
278#define __NR_clock_gettime (__NR_timer_create+6)
279#define __NR_clock_getres (__NR_timer_create+7)
280#define __NR_clock_nanosleep (__NR_timer_create+8)
281#define __NR_statfs64 268
282#define __NR_fstatfs64 269
283#define __NR_tgkill 270
284#define __NR_utimes 271
285#define __NR_fadvise64_64 272
286 /* 273 is reserved for vserver */
287#define __NR_mbind 274
288#define __NR_get_mempolicy 275
289#define __NR_set_mempolicy 276
290#define __NR_mq_open 277
291#define __NR_mq_unlink (__NR_mq_open+1)
292#define __NR_mq_timedsend (__NR_mq_open+2)
293#define __NR_mq_timedreceive (__NR_mq_open+3)
294#define __NR_mq_notify (__NR_mq_open+4)
295#define __NR_mq_getsetattr (__NR_mq_open+5)
296#define __NR_kexec_load 283
297#define __NR_waitid 284
298#define __NR_add_key 285
299#define __NR_request_key 286
300#define __NR_keyctl 287
301#define __NR_ioprio_set 288
302#define __NR_ioprio_get 289
303#define __NR_inotify_init 290
304#define __NR_inotify_add_watch 291
305#define __NR_inotify_rm_watch 292
306 /* 293 is unused */
307#define __NR_migrate_pages 294
308#define __NR_openat 295
309#define __NR_mkdirat 296
310#define __NR_mknodat 297
311#define __NR_fchownat 298
312#define __NR_futimesat 299
313#define __NR_fstatat64 300
314#define __NR_unlinkat 301
315#define __NR_renameat 302
316#define __NR_linkat 303
317#define __NR_symlinkat 304
318#define __NR_readlinkat 305
319#define __NR_fchmodat 306
320#define __NR_faccessat 307
321#define __NR_pselect6 308
322#define __NR_ppoll 309
323#define __NR_unshare 310
324#define __NR_set_robust_list 311
325#define __NR_get_robust_list 312
326#define __NR_splice 313
327#define __NR_sync_file_range 314
328#define __NR_tee 315
329#define __NR_vmsplice 316
330#define __NR_move_pages 317
331#define __NR_getcpu 318
332#define __NR_epoll_pwait 319
333#define __NR_utimensat 320
334#define __NR_signalfd 321
335#define __NR_timerfd_create 322
336#define __NR_eventfd 323
337#define __NR_fallocate 324
338#define __NR_timerfd_settime 325
339#define __NR_timerfd_gettime 326
340#define __NR_signalfd4 327
341#define __NR_eventfd2 328
342#define __NR_epoll_create1 329
343#define __NR_dup3 330
344#define __NR_pipe2 331
345#define __NR_inotify_init1 332
346#define __NR_preadv 333
347#define __NR_pwritev 334
348#define __NR_rt_tgsigqueueinfo 335
349#define __NR_perf_event_open 336
350#define __NR_fanotify_init 337
351#define __NR_fanotify_mark 338
352#define __NR_prlimit64 339
353
354/* Non-multiplexed socket family */
355#define __NR_socket 340
356#define __NR_bind 341
357#define __NR_connect 342
358#define __NR_listen 343
359#define __NR_accept 344
360#define __NR_getsockname 345
361#define __NR_getpeername 346
362#define __NR_socketpair 347
363#define __NR_send 348
364#define __NR_sendto 349
365#define __NR_recv 350
366#define __NR_recvfrom 351
367#define __NR_shutdown 352
368#define __NR_setsockopt 353
369#define __NR_getsockopt 354
370#define __NR_sendmsg 355
371#define __NR_recvmsg 356
372#define __NR_recvmmsg 357
373#define __NR_accept4 358
374#define __NR_name_to_handle_at 359
375#define __NR_open_by_handle_at 360
376#define __NR_clock_adjtime 361
377#define __NR_syncfs 362
378#define __NR_sendmmsg 363
379#define __NR_setns 364
380#define __NR_process_vm_readv 365
381#define __NR_process_vm_writev 366
382#define __NR_kcmp 367
383#define __NR_finit_module 368
384#define __NR_sched_getattr 369
385#define __NR_sched_setattr 370
386#define __NR_renameat2 371
387#define __NR_seccomp 372
388#define __NR_getrandom 373
389#define __NR_memfd_create 374
390#define __NR_bpf 375
391#define __NR_execveat 376
392#define __NR_userfaultfd 377
393#define __NR_membarrier 378
394#define __NR_mlock2 379
395#define __NR_copy_file_range 380
396#define __NR_preadv2 381
397#define __NR_pwritev2 382
398
399#define NR_syscalls 383
400
401#endif /* __ASM_SH_UNISTD_32_H */
libc/glibc/sysdeps/unix/sysv/linux/include/asm/unistd_64.h created+421
...@@ -0,0 +1,421 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef __ASM_SH_UNISTD_64_H
3#define __ASM_SH_UNISTD_64_H
4
5/*
6 * include/asm-sh/unistd_64.h
7 *
8 * This file contains the system call numbers.
9 *
10 * Copyright (C) 2000, 2001 Paolo Alberelli
11 * Copyright (C) 2003 - 2007 Paul Mundt
12 * Copyright (C) 2004 Sean McGoogan
13 *
14 * This file is subject to the terms and conditions of the GNU General Public
15 * License. See the file "COPYING" in the main directory of this archive
16 * for more details.
17 */
18#define __NR_restart_syscall 0
19#define __NR_exit 1
20#define __NR_fork 2
21#define __NR_read 3
22#define __NR_write 4
23#define __NR_open 5
24#define __NR_close 6
25#define __NR_waitpid 7
26#define __NR_creat 8
27#define __NR_link 9
28#define __NR_unlink 10
29#define __NR_execve 11
30#define __NR_chdir 12
31#define __NR_time 13
32#define __NR_mknod 14
33#define __NR_chmod 15
34#define __NR_lchown 16
35 /* 17 was sys_break */
36#define __NR_oldstat 18
37#define __NR_lseek 19
38#define __NR_getpid 20
39#define __NR_mount 21
40#define __NR_umount 22
41#define __NR_setuid 23
42#define __NR_getuid 24
43#define __NR_stime 25
44#define __NR_ptrace 26
45#define __NR_alarm 27
46#define __NR_oldfstat 28
47#define __NR_pause 29
48#define __NR_utime 30
49 /* 31 was sys_stty */
50 /* 32 was sys_gtty */
51#define __NR_access 33
52#define __NR_nice 34
53 /* 35 was sys_ftime */
54#define __NR_sync 36
55#define __NR_kill 37
56#define __NR_rename 38
57#define __NR_mkdir 39
58#define __NR_rmdir 40
59#define __NR_dup 41
60#define __NR_pipe 42
61#define __NR_times 43
62 /* 44 was sys_prof */
63#define __NR_brk 45
64#define __NR_setgid 46
65#define __NR_getgid 47
66#define __NR_signal 48
67#define __NR_geteuid 49
68#define __NR_getegid 50
69#define __NR_acct 51
70#define __NR_umount2 52
71 /* 53 was sys_lock */
72#define __NR_ioctl 54
73#define __NR_fcntl 55
74 /* 56 was sys_mpx */
75#define __NR_setpgid 57
76 /* 58 was sys_ulimit */
77 /* 59 was sys_olduname */
78#define __NR_umask 60
79#define __NR_chroot 61
80#define __NR_ustat 62
81#define __NR_dup2 63
82#define __NR_getppid 64
83#define __NR_getpgrp 65
84#define __NR_setsid 66
85#define __NR_sigaction 67
86#define __NR_sgetmask 68
87#define __NR_ssetmask 69
88#define __NR_setreuid 70
89#define __NR_setregid 71
90#define __NR_sigsuspend 72
91#define __NR_sigpending 73
92#define __NR_sethostname 74
93#define __NR_setrlimit 75
94#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
95#define __NR_getrusage 77
96#define __NR_gettimeofday 78
97#define __NR_settimeofday 79
98#define __NR_getgroups 80
99#define __NR_setgroups 81
100 /* 82 was sys_select */
101#define __NR_symlink 83
102#define __NR_oldlstat 84
103#define __NR_readlink 85
104#define __NR_uselib 86
105#define __NR_swapon 87
106#define __NR_reboot 88
107#define __NR_readdir 89
108#define __NR_mmap 90
109#define __NR_munmap 91
110#define __NR_truncate 92
111#define __NR_ftruncate 93
112#define __NR_fchmod 94
113#define __NR_fchown 95
114#define __NR_getpriority 96
115#define __NR_setpriority 97
116 /* 98 was sys_profil */
117#define __NR_statfs 99
118#define __NR_fstatfs 100
119 /* 101 was sys_ioperm */
120#define __NR_socketcall 102 /* old implementation of socket systemcall */
121#define __NR_syslog 103
122#define __NR_setitimer 104
123#define __NR_getitimer 105
124#define __NR_stat 106
125#define __NR_lstat 107
126#define __NR_fstat 108
127#define __NR_olduname 109
128 /* 110 was sys_iopl */
129#define __NR_vhangup 111
130 /* 112 was sys_idle */
131 /* 113 was sys_vm86old */
132#define __NR_wait4 114
133#define __NR_swapoff 115
134#define __NR_sysinfo 116
135#define __NR_ipc 117
136#define __NR_fsync 118
137#define __NR_sigreturn 119
138#define __NR_clone 120
139#define __NR_setdomainname 121
140#define __NR_uname 122
141#define __NR_cacheflush 123
142#define __NR_adjtimex 124
143#define __NR_mprotect 125
144#define __NR_sigprocmask 126
145 /* 127 was sys_create_module */
146#define __NR_init_module 128
147#define __NR_delete_module 129
148 /* 130 was sys_get_kernel_syms */
149#define __NR_quotactl 131
150#define __NR_getpgid 132
151#define __NR_fchdir 133
152#define __NR_bdflush 134
153#define __NR_sysfs 135
154#define __NR_personality 136
155 /* 137 was sys_afs_syscall */
156#define __NR_setfsuid 138
157#define __NR_setfsgid 139
158#define __NR__llseek 140
159#define __NR_getdents 141
160#define __NR__newselect 142
161#define __NR_flock 143
162#define __NR_msync 144
163#define __NR_readv 145
164#define __NR_writev 146
165#define __NR_getsid 147
166#define __NR_fdatasync 148
167#define __NR__sysctl 149
168#define __NR_mlock 150
169#define __NR_munlock 151
170#define __NR_mlockall 152
171#define __NR_munlockall 153
172#define __NR_sched_setparam 154
173#define __NR_sched_getparam 155
174#define __NR_sched_setscheduler 156
175#define __NR_sched_getscheduler 157
176#define __NR_sched_yield 158
177#define __NR_sched_get_priority_max 159
178#define __NR_sched_get_priority_min 160
179#define __NR_sched_rr_get_interval 161
180#define __NR_nanosleep 162
181#define __NR_mremap 163
182#define __NR_setresuid 164
183#define __NR_getresuid 165
184 /* 166 was sys_vm86 */
185 /* 167 was sys_query_module */
186#define __NR_poll 168
187#define __NR_nfsservctl 169
188#define __NR_setresgid 170
189#define __NR_getresgid 171
190#define __NR_prctl 172
191#define __NR_rt_sigreturn 173
192#define __NR_rt_sigaction 174
193#define __NR_rt_sigprocmask 175
194#define __NR_rt_sigpending 176
195#define __NR_rt_sigtimedwait 177
196#define __NR_rt_sigqueueinfo 178
197#define __NR_rt_sigsuspend 179
198#define __NR_pread64 180
199#define __NR_pwrite64 181
200#define __NR_chown 182
201#define __NR_getcwd 183
202#define __NR_capget 184
203#define __NR_capset 185
204#define __NR_sigaltstack 186
205#define __NR_sendfile 187
206 /* 188 reserved for getpmsg */
207 /* 189 reserved for putpmsg */
208#define __NR_vfork 190
209#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
210#define __NR_mmap2 192
211#define __NR_truncate64 193
212#define __NR_ftruncate64 194
213#define __NR_stat64 195
214#define __NR_lstat64 196
215#define __NR_fstat64 197
216#define __NR_lchown32 198
217#define __NR_getuid32 199
218#define __NR_getgid32 200
219#define __NR_geteuid32 201
220#define __NR_getegid32 202
221#define __NR_setreuid32 203
222#define __NR_setregid32 204
223#define __NR_getgroups32 205
224#define __NR_setgroups32 206
225#define __NR_fchown32 207
226#define __NR_setresuid32 208
227#define __NR_getresuid32 209
228#define __NR_setresgid32 210
229#define __NR_getresgid32 211
230#define __NR_chown32 212
231#define __NR_setuid32 213
232#define __NR_setgid32 214
233#define __NR_setfsuid32 215
234#define __NR_setfsgid32 216
235#define __NR_pivot_root 217
236#define __NR_mincore 218
237#define __NR_madvise 219
238
239/* Non-multiplexed socket family */
240#define __NR_socket 220
241#define __NR_bind 221
242#define __NR_connect 222
243#define __NR_listen 223
244#define __NR_accept 224
245#define __NR_getsockname 225
246#define __NR_getpeername 226
247#define __NR_socketpair 227
248#define __NR_send 228
249#define __NR_sendto 229
250#define __NR_recv 230
251#define __NR_recvfrom 231
252#define __NR_shutdown 232
253#define __NR_setsockopt 233
254#define __NR_getsockopt 234
255#define __NR_sendmsg 235
256#define __NR_recvmsg 236
257
258/* Non-multiplexed IPC family */
259#define __NR_semop 237
260#define __NR_semget 238
261#define __NR_semctl 239
262#define __NR_msgsnd 240
263#define __NR_msgrcv 241
264#define __NR_msgget 242
265#define __NR_msgctl 243
266#define __NR_shmat 244
267#define __NR_shmdt 245
268#define __NR_shmget 246
269#define __NR_shmctl 247
270
271#define __NR_getdents64 248
272#define __NR_fcntl64 249
273 /* 250 is reserved for tux */
274 /* 251 is unused */
275#define __NR_gettid 252
276#define __NR_readahead 253
277#define __NR_setxattr 254
278#define __NR_lsetxattr 255
279#define __NR_fsetxattr 256
280#define __NR_getxattr 257
281#define __NR_lgetxattr 258
282#define __NR_fgetxattr 259
283#define __NR_listxattr 260
284#define __NR_llistxattr 261
285#define __NR_flistxattr 262
286#define __NR_removexattr 263
287#define __NR_lremovexattr 264
288#define __NR_fremovexattr 265
289#define __NR_tkill 266
290#define __NR_sendfile64 267
291#define __NR_futex 268
292#define __NR_sched_setaffinity 269
293#define __NR_sched_getaffinity 270
294 /* 271 is reserved for set_thread_area */
295 /* 272 is reserved for get_thread_area */
296#define __NR_io_setup 273
297#define __NR_io_destroy 274
298#define __NR_io_getevents 275
299#define __NR_io_submit 276
300#define __NR_io_cancel 277
301#define __NR_fadvise64 278
302 /* 279 is unused */
303#define __NR_exit_group 280
304
305#define __NR_lookup_dcookie 281
306#define __NR_epoll_create 282
307#define __NR_epoll_ctl 283
308#define __NR_epoll_wait 284
309#define __NR_remap_file_pages 285
310#define __NR_set_tid_address 286
311#define __NR_timer_create 287
312#define __NR_timer_settime (__NR_timer_create+1)
313#define __NR_timer_gettime (__NR_timer_create+2)
314#define __NR_timer_getoverrun (__NR_timer_create+3)
315#define __NR_timer_delete (__NR_timer_create+4)
316#define __NR_clock_settime (__NR_timer_create+5)
317#define __NR_clock_gettime (__NR_timer_create+6)
318#define __NR_clock_getres (__NR_timer_create+7)
319#define __NR_clock_nanosleep (__NR_timer_create+8)
320#define __NR_statfs64 296
321#define __NR_fstatfs64 297
322#define __NR_tgkill 298
323#define __NR_utimes 299
324#define __NR_fadvise64_64 300
325 /* 301 is reserved for vserver */
326 /* 302 is reserved for mbind */
327 /* 303 is reserved for get_mempolicy */
328 /* 304 is reserved for set_mempolicy */
329#define __NR_mq_open 305
330#define __NR_mq_unlink (__NR_mq_open+1)
331#define __NR_mq_timedsend (__NR_mq_open+2)
332#define __NR_mq_timedreceive (__NR_mq_open+3)
333#define __NR_mq_notify (__NR_mq_open+4)
334#define __NR_mq_getsetattr (__NR_mq_open+5)
335 /* 311 is reserved for kexec */
336#define __NR_waitid 312
337#define __NR_add_key 313
338#define __NR_request_key 314
339#define __NR_keyctl 315
340#define __NR_ioprio_set 316
341#define __NR_ioprio_get 317
342#define __NR_inotify_init 318
343#define __NR_inotify_add_watch 319
344#define __NR_inotify_rm_watch 320
345 /* 321 is unused */
346#define __NR_migrate_pages 322
347#define __NR_openat 323
348#define __NR_mkdirat 324
349#define __NR_mknodat 325
350#define __NR_fchownat 326
351#define __NR_futimesat 327
352#define __NR_fstatat64 328
353#define __NR_unlinkat 329
354#define __NR_renameat 330
355#define __NR_linkat 331
356#define __NR_symlinkat 332
357#define __NR_readlinkat 333
358#define __NR_fchmodat 334
359#define __NR_faccessat 335
360#define __NR_pselect6 336
361#define __NR_ppoll 337
362#define __NR_unshare 338
363#define __NR_set_robust_list 339
364#define __NR_get_robust_list 340
365#define __NR_splice 341
366#define __NR_sync_file_range 342
367#define __NR_tee 343
368#define __NR_vmsplice 344
369#define __NR_move_pages 345
370#define __NR_getcpu 346
371#define __NR_epoll_pwait 347
372#define __NR_utimensat 348
373#define __NR_signalfd 349
374#define __NR_timerfd_create 350
375#define __NR_eventfd 351
376#define __NR_fallocate 352
377#define __NR_timerfd_settime 353
378#define __NR_timerfd_gettime 354
379#define __NR_signalfd4 355
380#define __NR_eventfd2 356
381#define __NR_epoll_create1 357
382#define __NR_dup3 358
383#define __NR_pipe2 359
384#define __NR_inotify_init1 360
385#define __NR_preadv 361
386#define __NR_pwritev 362
387#define __NR_rt_tgsigqueueinfo 363
388#define __NR_perf_event_open 364
389#define __NR_recvmmsg 365
390#define __NR_accept4 366
391#define __NR_fanotify_init 367
392#define __NR_fanotify_mark 368
393#define __NR_prlimit64 369
394#define __NR_name_to_handle_at 370
395#define __NR_open_by_handle_at 371
396#define __NR_clock_adjtime 372
397#define __NR_syncfs 373
398#define __NR_sendmmsg 374
399#define __NR_setns 375
400#define __NR_process_vm_readv 376
401#define __NR_process_vm_writev 377
402#define __NR_kcmp 378
403#define __NR_finit_module 379
404#define __NR_sched_getattr 380
405#define __NR_sched_setattr 381
406#define __NR_renameat2 382
407#define __NR_seccomp 383
408#define __NR_getrandom 384
409#define __NR_memfd_create 385
410#define __NR_bpf 386
411#define __NR_execveat 387
412#define __NR_userfaultfd 388
413#define __NR_membarrier 389
414#define __NR_mlock2 390
415#define __NR_copy_file_range 391
416#define __NR_preadv2 392
417#define __NR_pwritev2 393
418
419#define NR_syscalls 394
420
421#endif /* __ASM_SH_UNISTD_64_H */
libc/glibc/sysdeps/unix/sysv/linux/include/bits/syscall.h created+3
...@@ -0,0 +1,3 @@
1/* The real bits/syscall.h is generated during the build, in
2 $(objdir)/misc/bits. */
3#include <misc/bits/syscall.h>
libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h created+148
...@@ -0,0 +1,148 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* This file must not contain any C code. At least it must be protected
21 to allow using the file also in assembler files. */
22
23#ifndef __LINUX_KERNEL_VERSION
24/* We assume the worst; all kernels should be supported. */
25# define __LINUX_KERNEL_VERSION 0
26#endif
27
28/* We assume for __LINUX_KERNEL_VERSION the same encoding used in
29 linux/version.h. I.e., the major, minor, and subminor all get a
30 byte with the major number being in the highest byte. This means
31 we can do numeric comparisons.
32
33 In the following we will define certain symbols depending on
34 whether the describes kernel feature is available in the kernel
35 version given by __LINUX_KERNEL_VERSION. We are not always exactly
36 recording the correct versions in which the features were
37 introduced. If somebody cares these values can afterwards be
38 corrected. */
39
40/* The statfs64 syscalls are available in 2.5.74 (but not for alpha). */
41#define __ASSUME_STATFS64 1
42
43/* pselect/ppoll were introduced just after 2.6.16-rc1. On x86_64 and
44 SH this appeared first in 2.6.19-rc1, on ia64 in 2.6.22-rc1. */
45#define __ASSUME_PSELECT 1
46
47/* The *at syscalls were introduced just after 2.6.16-rc1. On PPC
48 they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1. */
49#define __ASSUME_ATFCTS 1
50
51/* Support for inter-process robust mutexes was added in 2.6.17 (but
52 some architectures lack futex_atomic_cmpxchg_inatomic in some
53 configurations). */
54#define __ASSUME_SET_ROBUST_LIST 1
55
56/* Support for various CLOEXEC and NONBLOCK flags was added in
57 2.6.27. */
58#define __ASSUME_IN_NONBLOCK 1
59
60/* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
61#define __ASSUME_FUTEX_CLOCK_REALTIME 1
62
63/* Support for preadv and pwritev was added in 2.6.30. */
64#define __ASSUME_PREADV 1
65#define __ASSUME_PWRITEV 1
66
67/* Support for sendmmsg functionality was added in 3.0. */
68#define __ASSUME_SENDMMSG 1
69
70/* On most architectures, most socket syscalls are supported for all
71 supported kernel versions, but on some socketcall architectures
72 separate syscalls were only added later. */
73#define __ASSUME_SENDMSG_SYSCALL 1
74#define __ASSUME_RECVMSG_SYSCALL 1
75#define __ASSUME_ACCEPT_SYSCALL 1
76#define __ASSUME_CONNECT_SYSCALL 1
77#define __ASSUME_RECVFROM_SYSCALL 1
78#define __ASSUME_SENDTO_SYSCALL 1
79#define __ASSUME_ACCEPT4_SYSCALL 1
80#define __ASSUME_RECVMMSG_SYSCALL 1
81#define __ASSUME_SENDMMSG_SYSCALL 1
82
83/* Support for SysV IPC through wired syscalls. All supported architectures
84 either support ipc syscall and/or all the ipc correspondent syscalls. */
85#define __ASSUME_DIRECT_SYSVIPC_SYSCALLS 1
86
87/* Support for p{read,write}v2 was added in 4.6. However Linux default
88 implementation does not assume the __ASSUME_* and instead use a fallback
89 implementation based on p{read,write}v and returning an error for
90 non supported flags. */
91
92/* Support for the renameat2 system call was added in kernel 3.15. */
93#if __LINUX_KERNEL_VERSION >= 0x030F00
94# define __ASSUME_RENAMEAT2
95#endif
96
97/* Support for the execveat syscall was added in 3.19. */
98#if __LINUX_KERNEL_VERSION >= 0x031300
99# define __ASSUME_EXECVEAT 1
100#endif
101
102#if __LINUX_KERNEL_VERSION >= 0x040400
103# define __ASSUME_MLOCK2 1
104#endif
105
106#if __LINUX_KERNEL_VERSION >= 0x040500
107# define __ASSUME_COPY_FILE_RANGE 1
108#endif
109
110/* Support for statx was added in kernel 4.11. */
111#if __LINUX_KERNEL_VERSION >= 0x040B00
112# define __ASSUME_STATX 1
113#endif
114
115/* Support for clone call used on fork. The signature varies across the
116 architectures with current 4 different variants:
117
118 1. long int clone (unsigned long flags, unsigned long newsp,
119 int *parent_tidptr, unsigned long tls,
120 int *child_tidptr)
121
122 2. long int clone (unsigned long newsp, unsigned long clone_flags,
123 int *parent_tidptr, int * child_tidptr,
124 unsigned long tls)
125
126 3. long int clone (unsigned long flags, unsigned long newsp,
127 int stack_size, int *parent_tidptr,
128 int *child_tidptr, unsigned long tls)
129
130 4. long int clone (unsigned long flags, unsigned long newsp,
131 int *parent_tidptr, int *child_tidptr,
132 unsigned long tls)
133
134 The fourth variant is intended to be used as the default for newer ports,
135 Also IA64 uses the third variant but with __NR_clone2 instead of
136 __NR_clone.
137
138 The macros names to define the variant used for the architecture is
139 similar to kernel:
140
141 - __ASSUME_CLONE_BACKWARDS: for variant 1.
142 - __ASSUME_CLONE_BACKWARDS2: for variant 2 (s390).
143 - __ASSUME_CLONE_BACKWARDS3: for variant 3 (microblaze).
144 - __ASSUME_CLONE_DEFAULT: for variant 4.
145 - __ASSUME_CLONE2: for clone2 with variant 3 (ia64).
146 */
147
148#define __ASSUME_CLONE_DEFAULT 1
libc/glibc/sysdeps/unix/sysv/linux/m68k/asm/unistd.h created+390
...@@ -0,0 +1,390 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef _UAPI_ASM_M68K_UNISTD_H_
3#define _UAPI_ASM_M68K_UNISTD_H_
4
5/*
6 * This file contains the system call numbers.
7 */
8
9#define __NR_restart_syscall 0
10#define __NR_exit 1
11#define __NR_fork 2
12#define __NR_read 3
13#define __NR_write 4
14#define __NR_open 5
15#define __NR_close 6
16#define __NR_waitpid 7
17#define __NR_creat 8
18#define __NR_link 9
19#define __NR_unlink 10
20#define __NR_execve 11
21#define __NR_chdir 12
22#define __NR_time 13
23#define __NR_mknod 14
24#define __NR_chmod 15
25#define __NR_chown 16
26/*#define __NR_break 17*/
27#define __NR_oldstat 18
28#define __NR_lseek 19
29#define __NR_getpid 20
30#define __NR_mount 21
31#define __NR_umount 22
32#define __NR_setuid 23
33#define __NR_getuid 24
34#define __NR_stime 25
35#define __NR_ptrace 26
36#define __NR_alarm 27
37#define __NR_oldfstat 28
38#define __NR_pause 29
39#define __NR_utime 30
40/*#define __NR_stty 31*/
41/*#define __NR_gtty 32*/
42#define __NR_access 33
43#define __NR_nice 34
44/*#define __NR_ftime 35*/
45#define __NR_sync 36
46#define __NR_kill 37
47#define __NR_rename 38
48#define __NR_mkdir 39
49#define __NR_rmdir 40
50#define __NR_dup 41
51#define __NR_pipe 42
52#define __NR_times 43
53/*#define __NR_prof 44*/
54#define __NR_brk 45
55#define __NR_setgid 46
56#define __NR_getgid 47
57#define __NR_signal 48
58#define __NR_geteuid 49
59#define __NR_getegid 50
60#define __NR_acct 51
61#define __NR_umount2 52
62/*#define __NR_lock 53*/
63#define __NR_ioctl 54
64#define __NR_fcntl 55
65/*#define __NR_mpx 56*/
66#define __NR_setpgid 57
67/*#define __NR_ulimit 58*/
68/*#define __NR_oldolduname 59*/
69#define __NR_umask 60
70#define __NR_chroot 61
71#define __NR_ustat 62
72#define __NR_dup2 63
73#define __NR_getppid 64
74#define __NR_getpgrp 65
75#define __NR_setsid 66
76#define __NR_sigaction 67
77#define __NR_sgetmask 68
78#define __NR_ssetmask 69
79#define __NR_setreuid 70
80#define __NR_setregid 71
81#define __NR_sigsuspend 72
82#define __NR_sigpending 73
83#define __NR_sethostname 74
84#define __NR_setrlimit 75
85#define __NR_getrlimit 76
86#define __NR_getrusage 77
87#define __NR_gettimeofday 78
88#define __NR_settimeofday 79
89#define __NR_getgroups 80
90#define __NR_setgroups 81
91#define __NR_select 82
92#define __NR_symlink 83
93#define __NR_oldlstat 84
94#define __NR_readlink 85
95#define __NR_uselib 86
96#define __NR_swapon 87
97#define __NR_reboot 88
98#define __NR_readdir 89
99#define __NR_mmap 90
100#define __NR_munmap 91
101#define __NR_truncate 92
102#define __NR_ftruncate 93
103#define __NR_fchmod 94
104#define __NR_fchown 95
105#define __NR_getpriority 96
106#define __NR_setpriority 97
107/*#define __NR_profil 98*/
108#define __NR_statfs 99
109#define __NR_fstatfs 100
110/*#define __NR_ioperm 101*/
111#define __NR_socketcall 102
112#define __NR_syslog 103
113#define __NR_setitimer 104
114#define __NR_getitimer 105
115#define __NR_stat 106
116#define __NR_lstat 107
117#define __NR_fstat 108
118/*#define __NR_olduname 109*/
119/*#define __NR_iopl 110*/ /* not supported */
120#define __NR_vhangup 111
121/*#define __NR_idle 112*/ /* Obsolete */
122/*#define __NR_vm86 113*/ /* not supported */
123#define __NR_wait4 114
124#define __NR_swapoff 115
125#define __NR_sysinfo 116
126#define __NR_ipc 117
127#define __NR_fsync 118
128#define __NR_sigreturn 119
129#define __NR_clone 120
130#define __NR_setdomainname 121
131#define __NR_uname 122
132#define __NR_cacheflush 123
133#define __NR_adjtimex 124
134#define __NR_mprotect 125
135#define __NR_sigprocmask 126
136#define __NR_create_module 127
137#define __NR_init_module 128
138#define __NR_delete_module 129
139#define __NR_get_kernel_syms 130
140#define __NR_quotactl 131
141#define __NR_getpgid 132
142#define __NR_fchdir 133
143#define __NR_bdflush 134
144#define __NR_sysfs 135
145#define __NR_personality 136
146/*#define __NR_afs_syscall 137*/ /* Syscall for Andrew File System */
147#define __NR_setfsuid 138
148#define __NR_setfsgid 139
149#define __NR__llseek 140
150#define __NR_getdents 141
151#define __NR__newselect 142
152#define __NR_flock 143
153#define __NR_msync 144
154#define __NR_readv 145
155#define __NR_writev 146
156#define __NR_getsid 147
157#define __NR_fdatasync 148
158#define __NR__sysctl 149
159#define __NR_mlock 150
160#define __NR_munlock 151
161#define __NR_mlockall 152
162#define __NR_munlockall 153
163#define __NR_sched_setparam 154
164#define __NR_sched_getparam 155
165#define __NR_sched_setscheduler 156
166#define __NR_sched_getscheduler 157
167#define __NR_sched_yield 158
168#define __NR_sched_get_priority_max 159
169#define __NR_sched_get_priority_min 160
170#define __NR_sched_rr_get_interval 161
171#define __NR_nanosleep 162
172#define __NR_mremap 163
173#define __NR_setresuid 164
174#define __NR_getresuid 165
175#define __NR_getpagesize 166
176#define __NR_query_module 167
177#define __NR_poll 168
178#define __NR_nfsservctl 169
179#define __NR_setresgid 170
180#define __NR_getresgid 171
181#define __NR_prctl 172
182#define __NR_rt_sigreturn 173
183#define __NR_rt_sigaction 174
184#define __NR_rt_sigprocmask 175
185#define __NR_rt_sigpending 176
186#define __NR_rt_sigtimedwait 177
187#define __NR_rt_sigqueueinfo 178
188#define __NR_rt_sigsuspend 179
189#define __NR_pread64 180
190#define __NR_pwrite64 181
191#define __NR_lchown 182
192#define __NR_getcwd 183
193#define __NR_capget 184
194#define __NR_capset 185
195#define __NR_sigaltstack 186
196#define __NR_sendfile 187
197#define __NR_getpmsg 188 /* some people actually want streams */
198#define __NR_putpmsg 189 /* some people actually want streams */
199#define __NR_vfork 190
200#define __NR_ugetrlimit 191
201#define __NR_mmap2 192
202#define __NR_truncate64 193
203#define __NR_ftruncate64 194
204#define __NR_stat64 195
205#define __NR_lstat64 196
206#define __NR_fstat64 197
207#define __NR_chown32 198
208#define __NR_getuid32 199
209#define __NR_getgid32 200
210#define __NR_geteuid32 201
211#define __NR_getegid32 202
212#define __NR_setreuid32 203
213#define __NR_setregid32 204
214#define __NR_getgroups32 205
215#define __NR_setgroups32 206
216#define __NR_fchown32 207
217#define __NR_setresuid32 208
218#define __NR_getresuid32 209
219#define __NR_setresgid32 210
220#define __NR_getresgid32 211
221#define __NR_lchown32 212
222#define __NR_setuid32 213
223#define __NR_setgid32 214
224#define __NR_setfsuid32 215
225#define __NR_setfsgid32 216
226#define __NR_pivot_root 217
227/* 218*/
228/* 219*/
229#define __NR_getdents64 220
230#define __NR_gettid 221
231#define __NR_tkill 222
232#define __NR_setxattr 223
233#define __NR_lsetxattr 224
234#define __NR_fsetxattr 225
235#define __NR_getxattr 226
236#define __NR_lgetxattr 227
237#define __NR_fgetxattr 228
238#define __NR_listxattr 229
239#define __NR_llistxattr 230
240#define __NR_flistxattr 231
241#define __NR_removexattr 232
242#define __NR_lremovexattr 233
243#define __NR_fremovexattr 234
244#define __NR_futex 235
245#define __NR_sendfile64 236
246#define __NR_mincore 237
247#define __NR_madvise 238
248#define __NR_fcntl64 239
249#define __NR_readahead 240
250#define __NR_io_setup 241
251#define __NR_io_destroy 242
252#define __NR_io_getevents 243
253#define __NR_io_submit 244
254#define __NR_io_cancel 245
255#define __NR_fadvise64 246
256#define __NR_exit_group 247
257#define __NR_lookup_dcookie 248
258#define __NR_epoll_create 249
259#define __NR_epoll_ctl 250
260#define __NR_epoll_wait 251
261#define __NR_remap_file_pages 252
262#define __NR_set_tid_address 253
263#define __NR_timer_create 254
264#define __NR_timer_settime 255
265#define __NR_timer_gettime 256
266#define __NR_timer_getoverrun 257
267#define __NR_timer_delete 258
268#define __NR_clock_settime 259
269#define __NR_clock_gettime 260
270#define __NR_clock_getres 261
271#define __NR_clock_nanosleep 262
272#define __NR_statfs64 263
273#define __NR_fstatfs64 264
274#define __NR_tgkill 265
275#define __NR_utimes 266
276#define __NR_fadvise64_64 267
277#define __NR_mbind 268
278#define __NR_get_mempolicy 269
279#define __NR_set_mempolicy 270
280#define __NR_mq_open 271
281#define __NR_mq_unlink 272
282#define __NR_mq_timedsend 273
283#define __NR_mq_timedreceive 274
284#define __NR_mq_notify 275
285#define __NR_mq_getsetattr 276
286#define __NR_waitid 277
287/*#define __NR_vserver 278*/
288#define __NR_add_key 279
289#define __NR_request_key 280
290#define __NR_keyctl 281
291#define __NR_ioprio_set 282
292#define __NR_ioprio_get 283
293#define __NR_inotify_init 284
294#define __NR_inotify_add_watch 285
295#define __NR_inotify_rm_watch 286
296#define __NR_migrate_pages 287
297#define __NR_openat 288
298#define __NR_mkdirat 289
299#define __NR_mknodat 290
300#define __NR_fchownat 291
301#define __NR_futimesat 292
302#define __NR_fstatat64 293
303#define __NR_unlinkat 294
304#define __NR_renameat 295
305#define __NR_linkat 296
306#define __NR_symlinkat 297
307#define __NR_readlinkat 298
308#define __NR_fchmodat 299
309#define __NR_faccessat 300
310#define __NR_pselect6 301
311#define __NR_ppoll 302
312#define __NR_unshare 303
313#define __NR_set_robust_list 304
314#define __NR_get_robust_list 305
315#define __NR_splice 306
316#define __NR_sync_file_range 307
317#define __NR_tee 308
318#define __NR_vmsplice 309
319#define __NR_move_pages 310
320#define __NR_sched_setaffinity 311
321#define __NR_sched_getaffinity 312
322#define __NR_kexec_load 313
323#define __NR_getcpu 314
324#define __NR_epoll_pwait 315
325#define __NR_utimensat 316
326#define __NR_signalfd 317
327#define __NR_timerfd_create 318
328#define __NR_eventfd 319
329#define __NR_fallocate 320
330#define __NR_timerfd_settime 321
331#define __NR_timerfd_gettime 322
332#define __NR_signalfd4 323
333#define __NR_eventfd2 324
334#define __NR_epoll_create1 325
335#define __NR_dup3 326
336#define __NR_pipe2 327
337#define __NR_inotify_init1 328
338#define __NR_preadv 329
339#define __NR_pwritev 330
340#define __NR_rt_tgsigqueueinfo 331
341#define __NR_perf_event_open 332
342#define __NR_get_thread_area 333
343#define __NR_set_thread_area 334
344#define __NR_atomic_cmpxchg_32 335
345#define __NR_atomic_barrier 336
346#define __NR_fanotify_init 337
347#define __NR_fanotify_mark 338
348#define __NR_prlimit64 339
349#define __NR_name_to_handle_at 340
350#define __NR_open_by_handle_at 341
351#define __NR_clock_adjtime 342
352#define __NR_syncfs 343
353#define __NR_setns 344
354#define __NR_process_vm_readv 345
355#define __NR_process_vm_writev 346
356#define __NR_kcmp 347
357#define __NR_finit_module 348
358#define __NR_sched_setattr 349
359#define __NR_sched_getattr 350
360#define __NR_renameat2 351
361#define __NR_getrandom 352
362#define __NR_memfd_create 353
363#define __NR_bpf 354
364#define __NR_execveat 355
365#define __NR_socket 356
366#define __NR_socketpair 357
367#define __NR_bind 358
368#define __NR_connect 359
369#define __NR_listen 360
370#define __NR_accept4 361
371#define __NR_getsockopt 362
372#define __NR_setsockopt 363
373#define __NR_getsockname 364
374#define __NR_getpeername 365
375#define __NR_sendto 366
376#define __NR_sendmsg 367
377#define __NR_recvfrom 368
378#define __NR_recvmsg 369
379#define __NR_shutdown 370
380#define __NR_recvmmsg 371
381#define __NR_sendmmsg 372
382#define __NR_userfaultfd 373
383#define __NR_membarrier 374
384#define __NR_mlock2 375
385#define __NR_copy_file_range 376
386#define __NR_preadv2 377
387#define __NR_pwritev2 378
388#define __NR_statx 379
389
390#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
libc/glibc/sysdeps/unix/sysv/linux/m68k/bits/stat.h created+172
...@@ -0,0 +1,172 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_LINUX_OLD 1
27#define _STAT_VER_KERNEL 1
28#define _STAT_VER_SVR4 2
29#define _STAT_VER_LINUX 3
30#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
31
32/* Versions of the `xmknod' interface. */
33#define _MKNOD_VER_LINUX 1
34#define _MKNOD_VER_SVR4 2
35#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36
37
38struct stat
39 {
40 __dev_t st_dev; /* Device. */
41 unsigned short int __pad1;
42#ifndef __USE_FILE_OFFSET64
43 __ino_t st_ino; /* File serial number. */
44#else
45 __ino_t __st_ino; /* 32bit file serial number. */
46#endif
47 __mode_t st_mode; /* File mode. */
48 __nlink_t st_nlink; /* Link count. */
49 __uid_t st_uid; /* User ID of the file's owner. */
50 __gid_t st_gid; /* Group ID of the file's group.*/
51 __dev_t st_rdev; /* Device number, if device. */
52 unsigned short int __pad2;
53#ifndef __USE_FILE_OFFSET64
54 __off_t st_size; /* Size of file, in bytes. */
55#else
56 __off64_t st_size; /* Size of file, in bytes. */
57#endif
58 __blksize_t st_blksize; /* Optimal block size for I/O. */
59
60#ifndef __USE_FILE_OFFSET64
61 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
62#else
63 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86#ifndef __USE_FILE_OFFSET64
87 unsigned long int __glibc_reserved4;
88 unsigned long int __glibc_reserved5;
89#else
90 __ino64_t st_ino; /* File serial number. */
91#endif
92 };
93
94#ifdef __USE_LARGEFILE64
95struct stat64
96 {
97 __dev_t st_dev; /* Device. */
98 unsigned short int __pad1;
99
100 __ino_t __st_ino; /* 32bit file serial number. */
101 __mode_t st_mode; /* File mode. */
102 __nlink_t st_nlink; /* Link count. */
103 __uid_t st_uid; /* User ID of the file's owner. */
104 __gid_t st_gid; /* Group ID of the file's group.*/
105 __dev_t st_rdev; /* Device number, if device. */
106 unsigned short int __pad2;
107 __off64_t st_size; /* Size of file, in bytes. */
108 __blksize_t st_blksize; /* Optimal block size for I/O. */
109
110 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
111# ifdef __USE_XOPEN2K8
112 /* Nanosecond resolution timestamps are stored in a format
113 equivalent to 'struct timespec'. This is the type used
114 whenever possible but the Unix namespace rules do not allow the
115 identifier 'timespec' to appear in the <sys/stat.h> header.
116 Therefore we have to handle the use of this header in strictly
117 standard-compliant sources special. */
118 struct timespec st_atim; /* Time of last access. */
119 struct timespec st_mtim; /* Time of last modification. */
120 struct timespec st_ctim; /* Time of last status change. */
121# else
122 __time_t st_atime; /* Time of last access. */
123 unsigned long int st_atimensec; /* Nscecs of last access. */
124 __time_t st_mtime; /* Time of last modification. */
125 unsigned long int st_mtimensec; /* Nsecs of last modification. */
126 __time_t st_ctime; /* Time of last status change. */
127 unsigned long int st_ctimensec; /* Nsecs of last status change. */
128# endif
129 __ino64_t st_ino; /* File serial number. */
130 };
131#endif
132
133/* Tell code we have these members. */
134#define _STATBUF_ST_BLKSIZE
135#define _STATBUF_ST_RDEV
136/* Nanosecond resolution time values are supported. */
137#define _STATBUF_ST_NSEC
138
139/* Encoding of the file mode. */
140
141#define __S_IFMT 0170000 /* These bits determine file type. */
142
143/* File types. */
144#define __S_IFDIR 0040000 /* Directory. */
145#define __S_IFCHR 0020000 /* Character device. */
146#define __S_IFBLK 0060000 /* Block device. */
147#define __S_IFREG 0100000 /* Regular file. */
148#define __S_IFIFO 0010000 /* FIFO. */
149#define __S_IFLNK 0120000 /* Symbolic link. */
150#define __S_IFSOCK 0140000 /* Socket. */
151
152/* POSIX.1b objects. Note that these macros always evaluate to zero. But
153 they do it by enforcing the correct use of the macros. */
154#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
155#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
156#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
157
158/* Protection bits. */
159
160#define __S_ISUID 04000 /* Set user ID on execution. */
161#define __S_ISGID 02000 /* Set group ID on execution. */
162#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
163#define __S_IREAD 0400 /* Read by owner. */
164#define __S_IWRITE 0200 /* Write by owner. */
165#define __S_IEXEC 0100 /* Execute by owner. */
166
167#ifdef __USE_ATFILE
168# define UTIME_NOW ((1l << 30) - 1l)
169# define UTIME_OMIT ((1l << 30) - 2l)
170#endif
171
172#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/m68k/coldfire/sysdep.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_M68K_COLDFIRE_SYSDEP_H
19#define _LINUX_M68K_COLDFIRE_SYSDEP_H 1
20
21#include <sysdeps/unix/sysdep.h>
22#include <sysdeps/m68k/coldfire/sysdep.h>
23#include <sysdeps/unix/sysv/linux/m68k/sysdep.h>
24
25#define SYSCALL_ERROR_LOAD_GOT(reg) \
26 move.l &_GLOBAL_OFFSET_TABLE_@GOTPC, reg; \
27 lea (-6, %pc, reg), reg
28
29#endif
libc/glibc/sysdeps/unix/sysv/linux/m68k/kernel-features.h created+54
...@@ -0,0 +1,54 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 2008-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* Direct socketcalls available with kernel 4.3. */
21#if __LINUX_KERNEL_VERSION >= 0x040300
22# define __ASSUME_SOCKET_SYSCALL 1
23# define __ASSUME_SOCKETPAIR_SYSCALL 1
24# define __ASSUME_BIND_SYSCALL 1
25# define __ASSUME_LISTEN_SYSCALL 1
26# define __ASSUME_GETSOCKOPT_SYSCALL 1
27# define __ASSUME_SETSOCKOPT_SYSCALL 1
28# define __ASSUME_GETSOCKNAME_SYSCALL 1
29# define __ASSUME_GETPEERNAME_SYSCALL 1
30# define __ASSUME_SHUTDOWN_SYSCALL 1
31#endif
32
33#include_next <kernel-features.h>
34
35#undef __ASSUME_ACCEPT_SYSCALL
36
37#if __LINUX_KERNEL_VERSION < 0x040300
38# undef __ASSUME_ACCEPT4_SYSCALL
39# undef __ASSUME_RECVMMSG_SYSCALL
40# undef __ASSUME_SENDMMSG_SYSCALL
41# undef __ASSUME_SENDMSG_SYSCALL
42# undef __ASSUME_RECVMSG_SYSCALL
43# undef __ASSUME_CONNECT_SYSCALL
44# undef __ASSUME_RECVFROM_SYSCALL
45# undef __ASSUME_SENDTO_SYSCALL
46#endif
47
48/* No support for PI futexes or robust mutexes before 3.10 for m68k. */
49#if __LINUX_KERNEL_VERSION < 0x030a00
50# undef __ASSUME_SET_ROBUST_LIST
51#endif
52
53/* m68k only supports ipc syscall. */
54#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
libc/glibc/sysdeps/unix/sysv/linux/m68k/m680x0/sysdep.h created+28
...@@ -0,0 +1,28 @@
1/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_M68K_M680X0_SYSDEP_H
19#define _LINUX_M68K_M680X0_SYSDEP_H 1
20
21#include <sysdeps/unix/sysdep.h>
22#include <sysdeps/m68k/m680x0/sysdep.h>
23#include <sysdeps/unix/sysv/linux/m68k/sysdep.h>
24
25#define SYSCALL_ERROR_LOAD_GOT(reg) \
26 lea (_GLOBAL_OFFSET_TABLE_@GOTPC, %pc), reg
27
28#endif
libc/glibc/sysdeps/unix/sysv/linux/m68k/sysdep.h created+326
...@@ -0,0 +1,326 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Written by Andreas Schwab, <schwab@issan.informatik.uni-dortmund.de>,
4 December 1995.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <sysdeps/unix/sysv/linux/sysdep.h>
21#include <tls.h>
22
23/* Defines RTLD_PRIVATE_ERRNO. */
24#include <dl-sysdep.h>
25
26/* For Linux we can use the system call table in the header file
27 /usr/include/asm/unistd.h
28 of the kernel. But these symbols do not follow the SYS_* syntax
29 so we have to redefine the `SYS_ify' macro here. */
30#undef SYS_ify
31#define SYS_ify(syscall_name) __NR_##syscall_name
32
33#ifdef __ASSEMBLER__
34
35/* Linux uses a negative return value to indicate syscall errors, unlike
36 most Unices, which use the condition codes' carry flag.
37
38 Since version 2.1 the return value of a system call might be negative
39 even if the call succeeded. E.g., the `lseek' system call might return
40 a large offset. Therefore we must not anymore test for < 0, but test
41 for a real error by making sure the value in %d0 is a real error
42 number. Linus said he will make sure the no syscall returns a value
43 in -1 .. -4095 as a valid result so we can savely test with -4095. */
44
45/* We don't want the label for the error handler to be visible in the symbol
46 table when we define it here. */
47#ifdef PIC
48#define SYSCALL_ERROR_LABEL .Lsyscall_error
49#else
50#define SYSCALL_ERROR_LABEL __syscall_error
51#endif
52
53#undef PSEUDO
54#define PSEUDO(name, syscall_name, args) \
55 .text; \
56 ENTRY (name) \
57 DO_CALL (syscall_name, args); \
58 cmp.l &-4095, %d0; \
59 jcc SYSCALL_ERROR_LABEL
60
61#undef PSEUDO_END
62#define PSEUDO_END(name) \
63 SYSCALL_ERROR_HANDLER; \
64 END (name)
65
66#undef PSEUDO_NOERRNO
67#define PSEUDO_NOERRNO(name, syscall_name, args) \
68 .text; \
69 ENTRY (name) \
70 DO_CALL (syscall_name, args)
71
72#undef PSEUDO_END_NOERRNO
73#define PSEUDO_END_NOERRNO(name) \
74 END (name)
75
76#define ret_NOERRNO rts
77
78/* The function has to return the error code. */
79#undef PSEUDO_ERRVAL
80#define PSEUDO_ERRVAL(name, syscall_name, args) \
81 .text; \
82 ENTRY (name) \
83 DO_CALL (syscall_name, args); \
84 negl %d0
85
86#undef PSEUDO_END_ERRVAL
87#define PSEUDO_END_ERRVAL(name) \
88 END (name)
89
90#define ret_ERRVAL rts
91
92#ifdef PIC
93# if RTLD_PRIVATE_ERRNO
94# define SYSCALL_ERROR_HANDLER \
95SYSCALL_ERROR_LABEL: \
96 PCREL_OP (lea, rtld_errno, %a0, %a0); \
97 neg.l %d0; \
98 move.l %d0, (%a0); \
99 move.l &-1, %d0; \
100 /* Copy return value to %a0 for syscalls that are declared to return \
101 a pointer (e.g., mmap). */ \
102 move.l %d0, %a0; \
103 rts;
104# elif defined _LIBC_REENTRANT
105# if IS_IN (libc)
106# define SYSCALL_ERROR_ERRNO __libc_errno
107# else
108# define SYSCALL_ERROR_ERRNO errno
109# endif
110# define SYSCALL_ERROR_HANDLER \
111SYSCALL_ERROR_LABEL: \
112 neg.l %d0; \
113 move.l %d0, -(%sp); \
114 cfi_adjust_cfa_offset (4); \
115 jbsr __m68k_read_tp@PLTPC; \
116 SYSCALL_ERROR_LOAD_GOT (%a1); \
117 add.l (SYSCALL_ERROR_ERRNO@TLSIE, %a1), %a0; \
118 move.l (%sp)+, (%a0); \
119 cfi_adjust_cfa_offset (-4); \
120 move.l &-1, %d0; \
121 /* Copy return value to %a0 for syscalls that are declared to return \
122 a pointer (e.g., mmap). */ \
123 move.l %d0, %a0; \
124 rts;
125# else /* !_LIBC_REENTRANT */
126/* Store (- %d0) into errno through the GOT. */
127# define SYSCALL_ERROR_HANDLER \
128SYSCALL_ERROR_LABEL: \
129 move.l (errno@GOTPC, %pc), %a0; \
130 neg.l %d0; \
131 move.l %d0, (%a0); \
132 move.l &-1, %d0; \
133 /* Copy return value to %a0 for syscalls that are declared to return \
134 a pointer (e.g., mmap). */ \
135 move.l %d0, %a0; \
136 rts;
137# endif /* _LIBC_REENTRANT */
138#else
139# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
140#endif /* PIC */
141
142/* Linux takes system call arguments in registers:
143
144 syscall number %d0 call-clobbered
145 arg 1 %d1 call-clobbered
146 arg 2 %d2 call-saved
147 arg 3 %d3 call-saved
148 arg 4 %d4 call-saved
149 arg 5 %d5 call-saved
150 arg 6 %a0 call-clobbered
151
152 The stack layout upon entering the function is:
153
154 24(%sp) Arg# 6
155 20(%sp) Arg# 5
156 16(%sp) Arg# 4
157 12(%sp) Arg# 3
158 8(%sp) Arg# 2
159 4(%sp) Arg# 1
160 (%sp) Return address
161
162 (Of course a function with say 3 arguments does not have entries for
163 arguments 4 and 5.)
164
165 Separate move's are faster than movem, but need more space. Since
166 speed is more important, we don't use movem. Since %a0 and %a1 are
167 scratch registers, we can use them for saving as well. */
168
169#define DO_CALL(syscall_name, args) \
170 move.l &SYS_ify(syscall_name), %d0; \
171 DOARGS_##args \
172 trap &0; \
173 UNDOARGS_##args
174
175#define DOARGS_0 /* No arguments to frob. */
176#define UNDOARGS_0 /* No arguments to unfrob. */
177#define _DOARGS_0(n) /* No arguments to frob. */
178
179#define DOARGS_1 _DOARGS_1 (4)
180#define _DOARGS_1(n) move.l n(%sp), %d1; _DOARGS_0 (n)
181#define UNDOARGS_1 UNDOARGS_0
182
183#define DOARGS_2 _DOARGS_2 (8)
184#define _DOARGS_2(n) move.l %d2, %a0; cfi_register (%d2, %a0); \
185 move.l n(%sp), %d2; _DOARGS_1 (n-4)
186#define UNDOARGS_2 UNDOARGS_1; move.l %a0, %d2; cfi_restore (%d2)
187
188#define DOARGS_3 _DOARGS_3 (12)
189#define _DOARGS_3(n) move.l %d3, %a1; cfi_register (%d3, %a1); \
190 move.l n(%sp), %d3; _DOARGS_2 (n-4)
191#define UNDOARGS_3 UNDOARGS_2; move.l %a1, %d3; cfi_restore (%d3)
192
193#define DOARGS_4 _DOARGS_4 (16)
194#define _DOARGS_4(n) move.l %d4, -(%sp); \
195 cfi_adjust_cfa_offset (4); cfi_rel_offset (%d4, 0); \
196 move.l n+4(%sp), %d4; _DOARGS_3 (n)
197#define UNDOARGS_4 UNDOARGS_3; move.l (%sp)+, %d4; \
198 cfi_adjust_cfa_offset (-4); cfi_restore (%d4)
199
200#define DOARGS_5 _DOARGS_5 (20)
201#define _DOARGS_5(n) move.l %d5, -(%sp); \
202 cfi_adjust_cfa_offset (4); cfi_rel_offset (%d5, 0); \
203 move.l n+4(%sp), %d5; _DOARGS_4 (n)
204#define UNDOARGS_5 UNDOARGS_4; move.l (%sp)+, %d5; \
205 cfi_adjust_cfa_offset (-4); cfi_restore (%d5)
206
207#define DOARGS_6 _DOARGS_6 (24)
208#define _DOARGS_6(n) _DOARGS_5 (n-4); move.l %a0, -(%sp); \
209 cfi_adjust_cfa_offset (4); \
210 move.l n+12(%sp), %a0;
211#define UNDOARGS_6 move.l (%sp)+, %a0; cfi_adjust_cfa_offset (-4); \
212 UNDOARGS_5
213
214
215#define ret rts
216#if 0 /* Not used by Linux */
217#define r0 %d0
218#define r1 %d1
219#define MOVE(x,y) movel x , y
220#endif
221
222#else /* not __ASSEMBLER__ */
223
224/* Define a macro which expands into the inline wrapper code for a system
225 call. */
226#undef INLINE_SYSCALL
227#define INLINE_SYSCALL(name, nr, args...) \
228 ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
229 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
230 { \
231 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
232 _sys_result = (unsigned int) -1; \
233 } \
234 (int) _sys_result; })
235
236#undef INTERNAL_SYSCALL_DECL
237#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
238
239/* Define a macro which expands inline into the wrapper code for a system
240 call. This use is for internal calls that do not need to handle errors
241 normally. It will never touch errno. This returns just what the kernel
242 gave back. */
243#undef INTERNAL_SYSCALL
244#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
245 ({ unsigned int _sys_result; \
246 { \
247 /* Load argument values in temporary variables
248 to perform side effects like function calls
249 before the call used registers are set. */ \
250 LOAD_ARGS_##nr (args) \
251 LOAD_REGS_##nr \
252 register int _d0 asm ("%d0") = name; \
253 asm volatile ("trap #0" \
254 : "=d" (_d0) \
255 : "0" (_d0) ASM_ARGS_##nr \
256 : "memory"); \
257 _sys_result = _d0; \
258 } \
259 (int) _sys_result; })
260#define INTERNAL_SYSCALL(name, err, nr, args...) \
261 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
262
263#undef INTERNAL_SYSCALL_ERROR_P
264#define INTERNAL_SYSCALL_ERROR_P(val, err) \
265 ((unsigned int) (val) >= -4095U)
266
267#undef INTERNAL_SYSCALL_ERRNO
268#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
269
270#define LOAD_ARGS_0()
271#define LOAD_REGS_0
272#define ASM_ARGS_0
273#define LOAD_ARGS_1(a1) \
274 LOAD_ARGS_0 () \
275 int __arg1 = (int) (a1);
276#define LOAD_REGS_1 \
277 register int _d1 asm ("d1") = __arg1; \
278 LOAD_REGS_0
279#define ASM_ARGS_1 ASM_ARGS_0, "d" (_d1)
280#define LOAD_ARGS_2(a1, a2) \
281 LOAD_ARGS_1 (a1) \
282 int __arg2 = (int) (a2);
283#define LOAD_REGS_2 \
284 register int _d2 asm ("d2") = __arg2; \
285 LOAD_REGS_1
286#define ASM_ARGS_2 ASM_ARGS_1, "d" (_d2)
287#define LOAD_ARGS_3(a1, a2, a3) \
288 LOAD_ARGS_2 (a1, a2) \
289 int __arg3 = (int) (a3);
290#define LOAD_REGS_3 \
291 register int _d3 asm ("d3") = __arg3; \
292 LOAD_REGS_2
293#define ASM_ARGS_3 ASM_ARGS_2, "d" (_d3)
294#define LOAD_ARGS_4(a1, a2, a3, a4) \
295 LOAD_ARGS_3 (a1, a2, a3) \
296 int __arg4 = (int) (a4);
297#define LOAD_REGS_4 \
298 register int _d4 asm ("d4") = __arg4; \
299 LOAD_REGS_3
300#define ASM_ARGS_4 ASM_ARGS_3, "d" (_d4)
301#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
302 LOAD_ARGS_4 (a1, a2, a3, a4) \
303 int __arg5 = (int) (a5);
304#define LOAD_REGS_5 \
305 register int _d5 asm ("d5") = __arg5; \
306 LOAD_REGS_4
307#define ASM_ARGS_5 ASM_ARGS_4, "d" (_d5)
308#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
309 LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
310 int __arg6 = (int) (a6);
311#define LOAD_REGS_6 \
312 register int _a0 asm ("a0") = __arg6; \
313 LOAD_REGS_5
314#define ASM_ARGS_6 ASM_ARGS_5, "a" (_a0)
315
316#endif /* not __ASSEMBLER__ */
317
318/* Pointer mangling is not yet supported for M68K. */
319#define PTR_MANGLE(var) (void) (var)
320#define PTR_DEMANGLE(var) (void) (var)
321
322#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
323/* M68K needs system-supplied DSO to access TLS helpers
324 even when statically linked. */
325# define NEED_STATIC_SYSINFO_DSO 1
326#endif
libc/glibc/sysdeps/unix/sysv/linux/microblaze/asm/unistd.h created+421
...@@ -0,0 +1,421 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * Copyright (C) 2007-2008 Michal Simek <monstr@monstr.eu>
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _UAPI_ASM_MICROBLAZE_UNISTD_H
12#define _UAPI_ASM_MICROBLAZE_UNISTD_H
13
14#define __NR_restart_syscall 0 /* ok */
15#define __NR_exit 1 /* ok */
16#define __NR_fork 2 /* not for no MMU - weird */
17#define __NR_read 3 /* ok */
18#define __NR_write 4 /* ok */
19#define __NR_open 5 /* openat */
20#define __NR_close 6 /* ok */
21#define __NR_waitpid 7 /* waitid */
22#define __NR_creat 8 /* openat */
23#define __NR_link 9 /* linkat */
24#define __NR_unlink 10 /* unlinkat */
25#define __NR_execve 11 /* ok */
26#define __NR_chdir 12 /* ok */
27#define __NR_time 13 /* obsolete -> sys_gettimeofday */
28#define __NR_mknod 14 /* mknodat */
29#define __NR_chmod 15 /* fchmodat */
30#define __NR_lchown 16 /* ok */
31#define __NR_break 17 /* don't know */
32#define __NR_oldstat 18 /* remove */
33#define __NR_lseek 19 /* ok */
34#define __NR_getpid 20 /* ok */
35#define __NR_mount 21 /* ok */
36#define __NR_umount 22 /* ok */ /* use only umount2 */
37#define __NR_setuid 23 /* ok */
38#define __NR_getuid 24 /* ok */
39#define __NR_stime 25 /* obsolete -> sys_settimeofday */
40#define __NR_ptrace 26 /* ok */
41#define __NR_alarm 27 /* obsolete -> sys_setitimer */
42#define __NR_oldfstat 28 /* remove */
43#define __NR_pause 29 /* obsolete -> sys_rt_sigtimedwait */
44#define __NR_utime 30 /* obsolete -> sys_utimesat */
45#define __NR_stty 31 /* remove */
46#define __NR_gtty 32 /* remove */
47#define __NR_access 33 /* faccessat */
48/* can be implemented by sys_setpriority */
49#define __NR_nice 34
50#define __NR_ftime 35 /* remove */
51#define __NR_sync 36 /* ok */
52#define __NR_kill 37 /* ok */
53#define __NR_rename 38 /* renameat */
54#define __NR_mkdir 39 /* mkdirat */
55#define __NR_rmdir 40 /* unlinkat */
56#define __NR_dup 41 /* ok */
57#define __NR_pipe 42 /* ok */
58#define __NR_times 43 /* ok */
59#define __NR_prof 44 /* remove */
60#define __NR_brk 45 /* ok -mmu, nommu specific */
61#define __NR_setgid 46 /* ok */
62#define __NR_getgid 47 /* ok */
63#define __NR_signal 48 /* obsolete -> sys_rt_sigaction */
64#define __NR_geteuid 49 /* ok */
65#define __NR_getegid 50 /* ok */
66#define __NR_acct 51 /* add it and then I can disable it */
67#define __NR_umount2 52 /* remove */
68#define __NR_lock 53 /* remove */
69#define __NR_ioctl 54 /* ok */
70#define __NR_fcntl 55 /* ok -> 64bit version*/
71#define __NR_mpx 56 /* remove */
72#define __NR_setpgid 57 /* ok */
73#define __NR_ulimit 58 /* remove */
74#define __NR_oldolduname 59 /* remove */
75#define __NR_umask 60 /* ok */
76#define __NR_chroot 61 /* ok */
77#define __NR_ustat 62 /* obsolete -> statfs64 */
78#define __NR_dup2 63 /* ok */
79#define __NR_getppid 64 /* ok */
80#define __NR_getpgrp 65 /* obsolete -> sys_getpgid */
81#define __NR_setsid 66 /* ok */
82#define __NR_sigaction 67 /* obsolete -> rt_sigaction */
83#define __NR_sgetmask 68 /* obsolete -> sys_rt_sigprocmask */
84#define __NR_ssetmask 69 /* obsolete ->sys_rt_sigprocmask */
85#define __NR_setreuid 70 /* ok */
86#define __NR_setregid 71 /* ok */
87#define __NR_sigsuspend 72 /* obsolete -> rt_sigsuspend */
88#define __NR_sigpending 73 /* obsolete -> sys_rt_sigpending */
89#define __NR_sethostname 74 /* ok */
90#define __NR_setrlimit 75 /* ok */
91#define __NR_getrlimit 76 /* ok Back compatible 2G limited rlimit */
92#define __NR_getrusage 77 /* ok */
93#define __NR_gettimeofday 78 /* ok */
94#define __NR_settimeofday 79 /* ok */
95#define __NR_getgroups 80 /* ok */
96#define __NR_setgroups 81 /* ok */
97#define __NR_select 82 /* obsolete -> sys_pselect6 */
98#define __NR_symlink 83 /* symlinkat */
99#define __NR_oldlstat 84 /* remove */
100#define __NR_readlink 85 /* obsolete -> sys_readlinkat */
101#define __NR_uselib 86 /* remove */
102#define __NR_swapon 87 /* ok */
103#define __NR_reboot 88 /* ok */
104#define __NR_readdir 89 /* remove ? */
105#define __NR_mmap 90 /* obsolete -> sys_mmap2 */
106#define __NR_munmap 91 /* ok - mmu and nommu */
107#define __NR_truncate 92 /* ok or truncate64 */
108#define __NR_ftruncate 93 /* ok or ftruncate64 */
109#define __NR_fchmod 94 /* ok */
110#define __NR_fchown 95 /* ok */
111#define __NR_getpriority 96 /* ok */
112#define __NR_setpriority 97 /* ok */
113#define __NR_profil 98 /* remove */
114#define __NR_statfs 99 /* ok or statfs64 */
115#define __NR_fstatfs 100 /* ok or fstatfs64 */
116#define __NR_ioperm 101 /* remove */
117#define __NR_socketcall 102 /* remove */
118#define __NR_syslog 103 /* ok */
119#define __NR_setitimer 104 /* ok */
120#define __NR_getitimer 105 /* ok */
121#define __NR_stat 106 /* remove */
122#define __NR_lstat 107 /* remove */
123#define __NR_fstat 108 /* remove */
124#define __NR_olduname 109 /* remove */
125#define __NR_iopl 110 /* remove */
126#define __NR_vhangup 111 /* ok */
127#define __NR_idle 112 /* remove */
128#define __NR_vm86old 113 /* remove */
129#define __NR_wait4 114 /* obsolete -> waitid */
130#define __NR_swapoff 115 /* ok */
131#define __NR_sysinfo 116 /* ok */
132#define __NR_ipc 117 /* remove - direct call */
133#define __NR_fsync 118 /* ok */
134#define __NR_sigreturn 119 /* obsolete -> sys_rt_sigreturn */
135#define __NR_clone 120 /* ok */
136#define __NR_setdomainname 121 /* ok */
137#define __NR_uname 122 /* remove */
138#define __NR_modify_ldt 123 /* remove */
139#define __NR_adjtimex 124 /* ok */
140#define __NR_mprotect 125 /* remove */
141#define __NR_sigprocmask 126 /* obsolete -> sys_rt_sigprocmask */
142#define __NR_create_module 127 /* remove */
143#define __NR_init_module 128 /* ok */
144#define __NR_delete_module 129 /* ok */
145#define __NR_get_kernel_syms 130 /* remove */
146#define __NR_quotactl 131 /* ok */
147#define __NR_getpgid 132 /* ok */
148#define __NR_fchdir 133 /* ok */
149#define __NR_bdflush 134 /* remove */
150#define __NR_sysfs 135 /* needed for busybox */
151#define __NR_personality 136 /* ok */
152#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
153#define __NR_setfsuid 138 /* ok */
154#define __NR_setfsgid 139 /* ok */
155#define __NR__llseek 140 /* remove only lseek */
156#define __NR_getdents 141 /* ok or getdents64 */
157#define __NR__newselect 142 /* remove */
158#define __NR_flock 143 /* ok */
159#define __NR_msync 144 /* remove */
160#define __NR_readv 145 /* ok */
161#define __NR_writev 146 /* ok */
162#define __NR_getsid 147 /* ok */
163#define __NR_fdatasync 148 /* ok */
164#define __NR__sysctl 149 /* remove */
165#define __NR_mlock 150 /* ok - nommu or mmu */
166#define __NR_munlock 151 /* ok - nommu or mmu */
167#define __NR_mlockall 152 /* ok - nommu or mmu */
168#define __NR_munlockall 153 /* ok - nommu or mmu */
169#define __NR_sched_setparam 154 /* ok */
170#define __NR_sched_getparam 155 /* ok */
171#define __NR_sched_setscheduler 156 /* ok */
172#define __NR_sched_getscheduler 157 /* ok */
173#define __NR_sched_yield 158 /* ok */
174#define __NR_sched_get_priority_max 159 /* ok */
175#define __NR_sched_get_priority_min 160 /* ok */
176#define __NR_sched_rr_get_interval 161 /* ok */
177#define __NR_nanosleep 162 /* ok */
178#define __NR_mremap 163 /* ok - nommu or mmu */
179#define __NR_setresuid 164 /* ok */
180#define __NR_getresuid 165 /* ok */
181#define __NR_vm86 166 /* remove */
182#define __NR_query_module 167 /* ok */
183#define __NR_poll 168 /* obsolete -> sys_ppoll */
184#define __NR_nfsservctl 169 /* ok */
185#define __NR_setresgid 170 /* ok */
186#define __NR_getresgid 171 /* ok */
187#define __NR_prctl 172 /* ok */
188#define __NR_rt_sigreturn 173 /* ok */
189#define __NR_rt_sigaction 174 /* ok */
190#define __NR_rt_sigprocmask 175 /* ok */
191#define __NR_rt_sigpending 176 /* ok */
192#define __NR_rt_sigtimedwait 177 /* ok */
193#define __NR_rt_sigqueueinfo 178 /* ok */
194#define __NR_rt_sigsuspend 179 /* ok */
195#define __NR_pread64 180 /* ok */
196#define __NR_pwrite64 181 /* ok */
197#define __NR_chown 182 /* obsolete -> fchownat */
198#define __NR_getcwd 183 /* ok */
199#define __NR_capget 184 /* ok */
200#define __NR_capset 185 /* ok */
201#define __NR_sigaltstack 186 /* remove */
202#define __NR_sendfile 187 /* ok -> exist 64bit version*/
203#define __NR_getpmsg 188 /* remove */
204/* remove - some people actually want streams */
205#define __NR_putpmsg 189
206/* for noMMU - group with clone -> maybe remove */
207#define __NR_vfork 190
208#define __NR_ugetrlimit 191 /* remove - SuS compliant getrlimit */
209#define __NR_mmap2 192 /* ok */
210#define __NR_truncate64 193 /* ok */
211#define __NR_ftruncate64 194 /* ok */
212#define __NR_stat64 195 /* remove _ARCH_WANT_STAT64 */
213#define __NR_lstat64 196 /* remove _ARCH_WANT_STAT64 */
214#define __NR_fstat64 197 /* remove _ARCH_WANT_STAT64 */
215#define __NR_lchown32 198 /* ok - without 32 */
216#define __NR_getuid32 199 /* ok - without 32 */
217#define __NR_getgid32 200 /* ok - without 32 */
218#define __NR_geteuid32 201 /* ok - without 32 */
219#define __NR_getegid32 202 /* ok - without 32 */
220#define __NR_setreuid32 203 /* ok - without 32 */
221#define __NR_setregid32 204 /* ok - without 32 */
222#define __NR_getgroups32 205 /* ok - without 32 */
223#define __NR_setgroups32 206 /* ok - without 32 */
224#define __NR_fchown32 207 /* ok - without 32 */
225#define __NR_setresuid32 208 /* ok - without 32 */
226#define __NR_getresuid32 209 /* ok - without 32 */
227#define __NR_setresgid32 210 /* ok - without 32 */
228#define __NR_getresgid32 211 /* ok - without 32 */
229#define __NR_chown32 212 /* ok - without 32 -obsolete -> fchownat */
230#define __NR_setuid32 213 /* ok - without 32 */
231#define __NR_setgid32 214 /* ok - without 32 */
232#define __NR_setfsuid32 215 /* ok - without 32 */
233#define __NR_setfsgid32 216 /* ok - without 32 */
234#define __NR_pivot_root 217 /* ok */
235#define __NR_mincore 218 /* ok */
236#define __NR_madvise 219 /* ok */
237#define __NR_getdents64 220 /* ok */
238#define __NR_fcntl64 221 /* ok */
239/* 223 is unused */
240#define __NR_gettid 224 /* ok */
241#define __NR_readahead 225 /* ok */
242#define __NR_setxattr 226 /* ok */
243#define __NR_lsetxattr 227 /* ok */
244#define __NR_fsetxattr 228 /* ok */
245#define __NR_getxattr 229 /* ok */
246#define __NR_lgetxattr 230 /* ok */
247#define __NR_fgetxattr 231 /* ok */
248#define __NR_listxattr 232 /* ok */
249#define __NR_llistxattr 233 /* ok */
250#define __NR_flistxattr 234 /* ok */
251#define __NR_removexattr 235 /* ok */
252#define __NR_lremovexattr 236 /* ok */
253#define __NR_fremovexattr 237 /* ok */
254#define __NR_tkill 238 /* ok */
255#define __NR_sendfile64 239 /* ok */
256#define __NR_futex 240 /* ok */
257#define __NR_sched_setaffinity 241 /* ok */
258#define __NR_sched_getaffinity 242 /* ok */
259#define __NR_set_thread_area 243 /* remove */
260#define __NR_get_thread_area 244 /* remove */
261#define __NR_io_setup 245 /* ok */
262#define __NR_io_destroy 246 /* ok */
263#define __NR_io_getevents 247 /* ok */
264#define __NR_io_submit 248 /* ok */
265#define __NR_io_cancel 249 /* ok */
266#define __NR_fadvise64 250 /* remove -> sys_fadvise64_64 */
267/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
268#define __NR_exit_group 252 /* ok */
269#define __NR_lookup_dcookie 253 /* ok */
270#define __NR_epoll_create 254 /* ok */
271#define __NR_epoll_ctl 255 /* ok */
272#define __NR_epoll_wait 256 /* obsolete -> sys_epoll_pwait */
273#define __NR_remap_file_pages 257 /* only for mmu */
274#define __NR_set_tid_address 258 /* ok */
275#define __NR_timer_create 259 /* ok */
276#define __NR_timer_settime (__NR_timer_create+1) /* 260 */ /* ok */
277#define __NR_timer_gettime (__NR_timer_create+2) /* 261 */ /* ok */
278#define __NR_timer_getoverrun (__NR_timer_create+3) /* 262 */ /* ok */
279#define __NR_timer_delete (__NR_timer_create+4) /* 263 */ /* ok */
280#define __NR_clock_settime (__NR_timer_create+5) /* 264 */ /* ok */
281#define __NR_clock_gettime (__NR_timer_create+6) /* 265 */ /* ok */
282#define __NR_clock_getres (__NR_timer_create+7) /* 266 */ /* ok */
283#define __NR_clock_nanosleep (__NR_timer_create+8) /* 267 */ /* ok */
284#define __NR_statfs64 268 /* ok */
285#define __NR_fstatfs64 269 /* ok */
286#define __NR_tgkill 270 /* ok */
287#define __NR_utimes 271 /* obsolete -> sys_futimesat */
288#define __NR_fadvise64_64 272 /* ok */
289#define __NR_vserver 273 /* ok */
290#define __NR_mbind 274 /* only for mmu */
291#define __NR_get_mempolicy 275 /* only for mmu */
292#define __NR_set_mempolicy 276 /* only for mmu */
293#define __NR_mq_open 277 /* ok */
294#define __NR_mq_unlink (__NR_mq_open+1) /* 278 */ /* ok */
295#define __NR_mq_timedsend (__NR_mq_open+2) /* 279 */ /* ok */
296#define __NR_mq_timedreceive (__NR_mq_open+3) /* 280 */ /* ok */
297#define __NR_mq_notify (__NR_mq_open+4) /* 281 */ /* ok */
298#define __NR_mq_getsetattr (__NR_mq_open+5) /* 282 */ /* ok */
299#define __NR_kexec_load 283 /* ok */
300#define __NR_waitid 284 /* ok */
301/* #define __NR_sys_setaltroot 285 */
302#define __NR_add_key 286 /* ok */
303#define __NR_request_key 287 /* ok */
304#define __NR_keyctl 288 /* ok */
305#define __NR_ioprio_set 289 /* ok */
306#define __NR_ioprio_get 290 /* ok */
307#define __NR_inotify_init 291 /* ok */
308#define __NR_inotify_add_watch 292 /* ok */
309#define __NR_inotify_rm_watch 293 /* ok */
310#define __NR_migrate_pages 294 /* mmu */
311#define __NR_openat 295 /* ok */
312#define __NR_mkdirat 296 /* ok */
313#define __NR_mknodat 297 /* ok */
314#define __NR_fchownat 298 /* ok */
315#define __NR_futimesat 299 /* obsolete -> sys_utimesat */
316#define __NR_fstatat64 300 /* stat64 */
317#define __NR_unlinkat 301 /* ok */
318#define __NR_renameat 302 /* ok */
319#define __NR_linkat 303 /* ok */
320#define __NR_symlinkat 304 /* ok */
321#define __NR_readlinkat 305 /* ok */
322#define __NR_fchmodat 306 /* ok */
323#define __NR_faccessat 307 /* ok */
324#define __NR_pselect6 308 /* ok */
325#define __NR_ppoll 309 /* ok */
326#define __NR_unshare 310 /* ok */
327#define __NR_set_robust_list 311 /* ok */
328#define __NR_get_robust_list 312 /* ok */
329#define __NR_splice 313 /* ok */
330#define __NR_sync_file_range 314 /* ok */
331#define __NR_tee 315 /* ok */
332#define __NR_vmsplice 316 /* ok */
333#define __NR_move_pages 317 /* mmu */
334#define __NR_getcpu 318 /* ok */
335#define __NR_epoll_pwait 319 /* ok */
336#define __NR_utimensat 320 /* ok */
337#define __NR_signalfd 321 /* ok */
338#define __NR_timerfd_create 322 /* ok */
339#define __NR_eventfd 323 /* ok */
340#define __NR_fallocate 324 /* ok */
341#define __NR_semtimedop 325 /* ok - semaphore group */
342#define __NR_timerfd_settime 326 /* ok */
343#define __NR_timerfd_gettime 327 /* ok */
344/* sysv ipc syscalls */
345#define __NR_semctl 328 /* ok */
346#define __NR_semget 329 /* ok */
347#define __NR_semop 330 /* ok */
348#define __NR_msgctl 331 /* ok */
349#define __NR_msgget 332 /* ok */
350#define __NR_msgrcv 333 /* ok */
351#define __NR_msgsnd 334 /* ok */
352#define __NR_shmat 335 /* ok */
353#define __NR_shmctl 336 /* ok */
354#define __NR_shmdt 337 /* ok */
355#define __NR_shmget 338 /* ok */
356
357
358#define __NR_signalfd4 339 /* new */
359#define __NR_eventfd2 340 /* new */
360#define __NR_epoll_create1 341 /* new */
361#define __NR_dup3 342 /* new */
362#define __NR_pipe2 343 /* new */
363#define __NR_inotify_init1 344 /* new */
364#define __NR_socket 345 /* new */
365#define __NR_socketpair 346 /* new */
366#define __NR_bind 347 /* new */
367#define __NR_listen 348 /* new */
368#define __NR_accept 349 /* new */
369#define __NR_connect 350 /* new */
370#define __NR_getsockname 351 /* new */
371#define __NR_getpeername 352 /* new */
372#define __NR_sendto 353 /* new */
373#define __NR_send 354 /* new */
374#define __NR_recvfrom 355 /* new */
375#define __NR_recv 356 /* new */
376#define __NR_setsockopt 357 /* new */
377#define __NR_getsockopt 358 /* new */
378#define __NR_shutdown 359 /* new */
379#define __NR_sendmsg 360 /* new */
380#define __NR_recvmsg 361 /* new */
381#define __NR_accept4 362 /* new */
382#define __NR_preadv 363 /* new */
383#define __NR_pwritev 364 /* new */
384#define __NR_rt_tgsigqueueinfo 365 /* new */
385#define __NR_perf_event_open 366 /* new */
386#define __NR_recvmmsg 367 /* new */
387#define __NR_fanotify_init 368
388#define __NR_fanotify_mark 369
389#define __NR_prlimit64 370
390#define __NR_name_to_handle_at 371
391#define __NR_open_by_handle_at 372
392#define __NR_clock_adjtime 373
393#define __NR_syncfs 374
394#define __NR_setns 375
395#define __NR_sendmmsg 376
396#define __NR_process_vm_readv 377
397#define __NR_process_vm_writev 378
398#define __NR_kcmp 379
399#define __NR_finit_module 380
400#define __NR_sched_setattr 381
401#define __NR_sched_getattr 382
402#define __NR_renameat2 383
403#define __NR_seccomp 384
404#define __NR_getrandom 385
405#define __NR_memfd_create 386
406#define __NR_bpf 387
407#define __NR_execveat 388
408#define __NR_userfaultfd 389
409#define __NR_membarrier 390
410#define __NR_mlock2 391
411#define __NR_copy_file_range 392
412#define __NR_preadv2 393
413#define __NR_pwritev2 394
414#define __NR_pkey_mprotect 395
415#define __NR_pkey_alloc 396
416#define __NR_pkey_free 397
417#define __NR_statx 398
418#define __NR_io_pgetevents 399
419#define __NR_rseq 400
420
421#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/microblaze/bits/stat.h created+203
...@@ -0,0 +1,203 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_STAT_H && !defined _FCNTL_H
20# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
21#endif
22
23#ifndef _BITS_STAT_H
24#define _BITS_STAT_H 1
25
26/* Versions of the `struct stat' data structure. */
27#define _STAT_VER_LINUX_OLD 1
28#define _STAT_VER_KERNEL 1
29#define _STAT_VER_SVR4 2
30#define _STAT_VER_LINUX 3
31#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
32
33/* Versions of the `xmknod' interface. */
34#define _MKNOD_VER_LINUX 1
35#define _MKNOD_VER_SVR4 2
36#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
37
38#ifndef __USE_FILE_OFFSET64
39struct stat
40{
41 __dev_t st_dev; /* Device. */
42 __ino_t st_ino; /* File serial number. */
43 __mode_t st_mode; /* File mode. */
44 __nlink_t st_nlink; /* Link count. */
45 __uid_t st_uid; /* User ID of the file's owner. */
46 __gid_t st_gid; /* Group ID of the file's group. */
47 __dev_t st_rdev; /* Device number, if device. */
48 unsigned long __pad2;
49 __off_t st_size; /* Size of file, in bytes. */
50 __blksize_t st_blksize; /* Optimal block size for I/O. */
51 int __pad3;
52 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
53#ifdef __USE_XOPEN2K8
54 /* Nanosecond resolution timestamps are stored in a format
55 * equivalent to 'struct timespec'. This is the type used
56 * whenever possible but the Unix namespace rules do not allow the
57 * identifier 'timespec' to appear in the <sys/stat.h> header.
58 * Therefore we have to handle the use of this header in strictly
59 * standard-compliant sources special. */
60 struct timespec st_atim; /* Time of last access. */
61 struct timespec st_mtim; /* Time of last modification. */
62 struct timespec st_ctim; /* Time of last status change. */
63# define st_atime st_atim.tv_sec /* Backward compatibility. */
64# define st_mtime st_mtim.tv_sec
65# define st_ctime st_ctim.tv_sec
66#else
67 __time_t st_atime; /* Time of last access. */
68 unsigned long int st_atimensec; /* Nscecs of last access. */
69 __time_t st_mtime; /* Time of last modification. */
70 unsigned long int st_mtimensec; /* Nsecs of last modification. */
71 __time_t st_ctime; /* Time of last status change. */
72 unsigned long int st_ctimensec; /* Nsecs of last status change. */
73#endif
74 unsigned int __glibc_reserved4;
75 unsigned int __glibc_reserved5;
76};
77#else /* __USE_FILE_OFFSET64 */
78/* MS: If __USE_FILE_OFFSET64 is setup then struct stat should match stat64
79 * structure. Glibc has no type __dev64_t that's why I had to use standard
80 * type for st_dev and st_rdev. Several architectures uses pads after st_dev
81 * but this approach covers BIG and LITTLE endian. I think it is better to
82 * create one ifdef to separate stats structures. */
83struct stat
84{
85 unsigned long long st_dev; /* Device. */
86 __ino64_t st_ino; /* 32bit file serial number. */
87 __mode_t st_mode; /* File mode. */
88 __nlink_t st_nlink; /* Link count. */
89 __uid_t st_uid; /* User ID of the file's owner. */
90 __gid_t st_gid; /* Group ID of the file's group. */
91 unsigned long long st_rdev; /* Device number, if device. */
92 unsigned long long __pad2;
93 __off64_t st_size; /* Size of file, in bytes. */
94 __blksize_t st_blksize; /* Optimal block size for I/O. */
95 int __pad3;
96 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
97#ifdef __USE_MISC
98 /* Nanosecond resolution timestamps are stored in a format
99 * equivalent to 'struct timespec'. This is the type used
100 * whenever possible but the Unix namespace rules do not allow the
101 * identifier 'timespec' to appear in the <sys/stat.h> header.
102 * Therefore we have to handle the use of this header in strictly
103 * standard-compliant sources special. */
104 struct timespec st_atim; /* Time of last access. */
105 struct timespec st_mtim; /* Time of last modification. */
106 struct timespec st_ctim; /* Time of last status change. */
107# define st_atime st_atim.tv_sec /* Backward compatibility. */
108# define st_mtime st_mtim.tv_sec
109# define st_ctime st_ctim.tv_sec
110#else
111 __time_t st_atime; /* Time of last access. */
112 unsigned long int st_atimensec; /* Nscecs of last access. */
113 __time_t st_mtime; /* Time of last modification. */
114 unsigned long int st_mtimensec; /* Nsecs of last modification. */
115 __time_t st_ctime; /* Time of last status change. */
116 unsigned long int st_ctimensec; /* Nsecs of last status change. */
117#endif
118 unsigned int __glibc_reserved4;
119 unsigned int __glibc_reserved5;
120};
121#endif /* __USE_FILE_OFFSET64 */
122
123#ifdef __USE_LARGEFILE64
124struct stat64
125{
126 unsigned long long st_dev; /* Device. */
127 __ino64_t st_ino; /* 32bit file serial number. */
128 __mode_t st_mode; /* File mode. */
129 __nlink_t st_nlink; /* Link count. */
130 __uid_t st_uid; /* User ID of the file's owner. */
131 __gid_t st_gid; /* Group ID of the file's group. */
132 unsigned long long st_rdev; /* Device number, if device. */
133 unsigned long long __pad2;
134 __off64_t st_size; /* Size of file, in bytes. */
135 __blksize_t st_blksize; /* Optimal block size for I/O. */
136 int __pad3;
137 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
138#ifdef __USE_XOPEN2K8
139 /* Nanosecond resolution timestamps are stored in a format
140 * equivalent to 'struct timespec'. This is the type used
141 * whenever possible but the Unix namespace rules do not allow the
142 * identifier 'timespec' to appear in the <sys/stat.h> header.
143 * Therefore we have to handle the use of this header in strictly
144 * standard-compliant sources special. */
145 struct timespec st_atim; /* Time of last access. */
146 struct timespec st_mtim; /* Time of last modification. */
147 struct timespec st_ctim; /* Time of last status change. */
148# define st_atime st_atim.tv_sec /* Backward compatibility. */
149# define st_mtime st_mtim.tv_sec
150# define st_ctime st_ctim.tv_sec
151#else
152 __time_t st_atime; /* Time of last access. */
153 unsigned long int st_atimensec; /* Nscecs of last access. */
154 __time_t st_mtime; /* Time of last modification. */
155 unsigned long int st_mtimensec; /* Nsecs of last modification. */
156 __time_t st_ctime; /* Time of last status change. */
157 unsigned long int st_ctimensec; /* Nsecs of last status change. */
158#endif
159 unsigned int __glibc_reserved4;
160 unsigned int __glibc_reserved5;
161};
162#endif
163
164/* Tell code we have these members. */
165#define _STATBUF_ST_BLKSIZE
166#define _STATBUF_ST_RDEV
167/* Nanosecond resolution time values are supported. */
168#define _STATBUF_ST_NSEC
169
170/* Encoding of the file mode. */
171
172#define __S_IFMT 0170000 /* These bits determine file type. */
173
174/* File types. */
175#define __S_IFDIR 0040000 /* Directory. */
176#define __S_IFCHR 0020000 /* Character device. */
177#define __S_IFBLK 0060000 /* Block device. */
178#define __S_IFREG 0100000 /* Regular file. */
179#define __S_IFIFO 0010000 /* FIFO. */
180#define __S_IFLNK 0120000 /* Symbolic link. */
181#define __S_IFSOCK 0140000 /* Socket. */
182
183/* POSIX.1b objects. Note that these macros always evaluate to zero. But
184 they do it by enforcing the correct use of the macros. */
185#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
186#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
187#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
188
189/* Protection bits. */
190
191#define __S_ISUID 04000 /* Set user ID on execution. */
192#define __S_ISGID 02000 /* Set group ID on execution. */
193#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
194#define __S_IREAD 0400 /* Read by owner. */
195#define __S_IWRITE 0200 /* Write by owner. */
196#define __S_IEXEC 0100 /* Execute by owner. */
197
198#ifdef __USE_ATFILE
199# define UTIME_NOW ((1l << 30) - 1l)
200# define UTIME_OMIT ((1l << 30) - 2l)
201#endif
202
203#endif /* bits/stat.h. */
libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h created+74
...@@ -0,0 +1,74 @@
1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18
19/* All supported kernel versions for MicroBlaze have these syscalls. */
20#define __ASSUME_SOCKET_SYSCALL 1
21#define __ASSUME_BIND_SYSCALL 1
22#define __ASSUME_CONNECT_SYSCALL 1
23#define __ASSUME_LISTEN_SYSCALL 1
24#define __ASSUME_GETSOCKNAME_SYSCALL 1
25#define __ASSUME_GETPEERNAME_SYSCALL 1
26#define __ASSUME_SOCKETPAIR_SYSCALL 1
27#define __ASSUME_SEND_SYSCALL 1
28#define __ASSUME_RECV_SYSCALL 1
29#define __ASSUME_SHUTDOWN_SYSCALL 1
30#define __ASSUME_GETSOCKOPT_SYSCALL 1
31#define __ASSUME_SETSOCKOPT_SYSCALL 1
32
33#include_next <kernel-features.h>
34
35/* Support for the pselect6, preadv and pwritev syscalls was added in
36 3.15. */
37#if __LINUX_KERNEL_VERSION < 0x030f00
38# undef __ASSUME_PSELECT
39# undef __ASSUME_PREADV
40# undef __ASSUME_PWRITEV
41#endif
42
43/* Support for the sendmmsg syscall was added in 3.3. */
44#if __LINUX_KERNEL_VERSION < 0x030300
45# undef __ASSUME_SENDMMSG_SYSCALL
46#endif
47
48/* Support for the renameat2 syscall was added in 3.17. */
49#if __LINUX_KERNEL_VERSION < 0x031100
50# undef __ASSUME_RENAMEAT2
51#endif
52
53/* Support for the execveat syscall was added in 4.0. */
54#if __LINUX_KERNEL_VERSION < 0x040000
55# undef __ASSUME_EXECVEAT
56#endif
57
58/* Support for the mlock2 syscall was added in 4.7. */
59#if __LINUX_KERNEL_VERSION < 0x040700
60# undef __ASSUME_MLOCK2
61#endif
62
63/* Support for the copy_file_range syscall was added in 4.10. */
64#if __LINUX_KERNEL_VERSION < 0x040A00
65# undef __ASSUME_COPY_FILE_RANGE
66#endif
67
68/* Support for statx was added in kernel 4.12. */
69#if __LINUX_KERNEL_VERSION < 0X040C00
70# undef __ASSUME_STATX
71#endif
72
73#undef __ASSUME_CLONE_DEFAULT
74#define __ASSUME_CLONE_BACKWARDS3
libc/glibc/sysdeps/unix/sysv/linux/microblaze/sysdep.h created+315
...@@ -0,0 +1,315 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_MICROBLAZE_SYSDEP_H
20#define _LINUX_MICROBLAZE_SYSDEP_H 1
21
22#include <sysdeps/unix/sysdep.h>
23#include <sysdeps/unix/sysv/linux/sysdep.h>
24#include <sysdeps/microblaze/sysdep.h>
25
26/* Defines RTLD_PRIVATE_ERRNO. */
27#include <dl-sysdep.h>
28
29/* In order to get __set_errno() definition in INLINE_SYSCALL. */
30#ifndef __ASSEMBLER__
31# include <errno.h>
32#endif
33
34/* For Linux we can use the system call table in the header file
35 /usr/include/asm/unistd.h
36 of the kernel. But these symbols do not follow the SYS_* syntax
37 so we have to redefine the `SYS_ify' macro here. */
38#undef SYS_ify
39#define SYS_ify(syscall_name) __NR_##syscall_name
40
41#ifdef __ASSEMBLER__
42
43/* In microblaze ABI function call arguments are passed in registers
44 r5...r10. The return value is stored in r3 (or r3:r4 regiters pair).
45 Linux syscall uses the same convention with the addition that the
46 syscall number is passed in r12. To enter the kernel "brki r14,8"
47 instruction is used.
48 None of the abovementioned registers are presumed across function call
49 or syscall.
50*/
51/* Linux uses a negative return value to indicate syscall errors, unlike
52 most Unices, which use the condition codes' carry flag.
53
54 Since version 2.1 the return value of a system call might be negative
55 even if the call succeeded. E.g., the `lseek' system call might return
56 a large offset. Therefore we must not anymore test for < 0, but test
57 for a real error by making sure the value in %d0 is a real error
58 number. Linus said he will make sure the no syscall returns a value
59 in -1 .. -4095 as a valid result so we can savely test with -4095. */
60
61/* We don't want the label for the error handler to be visible in the symbol
62 table when we define it here. */
63# ifdef PIC
64# define SYSCALL_ERROR_LABEL 0f
65# else
66# define SYSCALL_ERROR_LABEL __syscall_error
67# endif
68
69# undef PSEUDO
70# define PSEUDO(name, syscall_name, args) \
71 .text; \
72 ENTRY (name) \
73 DO_CALL (syscall_name, args); \
74 addik r12,r0,-4095; \
75 cmpu r12,r12,r3; \
76 bgei r12,SYSCALL_ERROR_LABEL;
77
78# undef PSEUDO_END
79# define PSEUDO_END(name) \
80 SYSCALL_ERROR_HANDLER; \
81 END (name)
82
83# undef PSEUDO_NOERRNO
84# define PSEUDO_NOERRNO(name, syscall_name, args) \
85 .text; \
86 ENTRY (name) \
87 DO_CALL (syscall_name, args);
88
89# undef PSEUDO_END_NOERRNO
90# define PSEUDO_END_NOERRNO(name) \
91 END (name)
92
93/* The function has to return the error code. */
94# undef PSEUDO_ERRVAL
95# define PSEUDO_ERRVAL(name, syscall_name, args) \
96 .text; \
97 ENTRY (name) \
98 DO_CALL (syscall_name, args); \
99
100# undef PSEUDO_END_ERRVAL
101# define PSEUDO_END_ERRVAL(name) \
102 END (name)
103
104# define ret_NOERRNO \
105 rtsd r15,8; addk r0,r0,r0;
106
107# define ret_ERRVAL \
108 rtsd r15,8; rsubk r3,r3,r0;
109
110# ifdef PIC
111# define SYSCALL_ERROR_LABEL_DCL 0
112# if RTLD_PRIVATE_ERRNO
113# define SYSCALL_ERROR_HANDLER \
114SYSCALL_ERROR_LABEL_DCL: \
115 mfs r12,rpc; \
116 addik r12,r12,_GLOBAL_OFFSET_TABLE_+8; \
117 lwi r12,r12,rtld_errno@GOT; \
118 rsubk r3,r3,r0; \
119 swi r3,r12,0; \
120 rtsd r15,8; \
121 addik r3,r0,-1;
122# else /* !RTLD_PRIVATE_ERRNO. */
123/* Store (-r3) into errno through the GOT. */
124# if defined _LIBC_REENTRANT
125# define SYSCALL_ERROR_HANDLER \
126SYSCALL_ERROR_LABEL_DCL: \
127 addik r1,r1,-16; \
128 swi r15,r1,0; \
129 swi r20,r1,8; \
130 rsubk r3,r3,r0; \
131 swi r3,r1,12; \
132 mfs r20,rpc; \
133 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8; \
134 brlid r15,__errno_location@PLT; \
135 nop; \
136 lwi r4,r1,12; \
137 swi r4,r3,0; \
138 lwi r20,r1,8; \
139 lwi r15,r1,0; \
140 addik r1,r1,16; \
141 rtsd r15,8; \
142 addik r3,r0,-1;
143# else /* !_LIBC_REENTRANT. */
144# define SYSCALL_ERROR_HANDLER \
145SYSCALL_ERROR_LABEL_DCL: \
146 mfs r12,rpc; \
147 addik r12,r12,_GLOBAL_OFFSET_TABLE_+8; \
148 lwi r12,r12,errno@GOT; \
149 rsubk r3,r3,r0; \
150 swi r3,r12,0; \
151 rtsd r15,8; \
152 addik r3,r0,-1;
153# endif /* _LIBC_REENTRANT. */
154# endif /* RTLD_PRIVATE_ERRNO. */
155# else
156# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
157# endif /* PIC. */
158
159# define DO_CALL(syscall_name, args) \
160 addik r12,r0,SYS_ify (syscall_name); \
161 brki r14,8; \
162 addk r0,r0,r0;
163
164#else /* not __ASSEMBLER__ */
165
166/* Define a macro which expands into the inline wrapper code for a system
167 call. */
168# undef INLINE_SYSCALL
169# define INLINE_SYSCALL(name, nr, args...) \
170({ INTERNAL_SYSCALL_DECL(err); \
171 unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args); \
172 if (INTERNAL_SYSCALL_ERROR_P (resultvar, err)) \
173 { \
174 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err)); \
175 resultvar = (unsigned long) -1; \
176 } \
177 (long) resultvar; \
178})
179
180# undef INTERNAL_SYSCALL_DECL
181# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
182
183/* Define a macro which expands inline into the wrapper code for a system
184 call. This use is for internal calls that do not need to handle errors
185 normally. It will never touch errno. This returns just what the kernel
186 gave back. */
187# undef INTERNAL_SYSCALL
188# define INTERNAL_SYSCALL(name, err, nr, args...) \
189 inline_syscall##nr(SYS_ify(name), args)
190
191# undef INTERNAL_SYSCALL_NCS
192# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
193 inline_syscall##nr(name, args)
194
195# undef INTERNAL_SYSCALL_ERROR_P
196# define INTERNAL_SYSCALL_ERROR_P(val, err) \
197 ((unsigned int) (val) >= -4095U)
198
199# undef INTERNAL_SYSCALL_ERRNO
200# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
201
202# define SYSCALL_CLOBBERS_6 "r11", "r4", "memory"
203# define SYSCALL_CLOBBERS_5 "r10", SYSCALL_CLOBBERS_6
204# define SYSCALL_CLOBBERS_4 "r9", SYSCALL_CLOBBERS_5
205# define SYSCALL_CLOBBERS_3 "r8", SYSCALL_CLOBBERS_4
206# define SYSCALL_CLOBBERS_2 "r7", SYSCALL_CLOBBERS_3
207# define SYSCALL_CLOBBERS_1 "r6", SYSCALL_CLOBBERS_2
208# define SYSCALL_CLOBBERS_0 "r5", SYSCALL_CLOBBERS_1
209
210# define inline_syscall0(name,dummy) \
211 ({ \
212 register long __ret __asm__("r3"); \
213 register long __r12 __asm__("r12") = name; \
214 __asm__ __volatile__( "brki r14,8; nop;" \
215 : "=r"(__ret) \
216 : "r"(__r12) \
217 : SYSCALL_CLOBBERS_0 ); __ret; \
218 })
219
220# define inline_syscall1(name,arg1) \
221 ({ \
222 register long __ret __asm__("r3"); \
223 register long __r12 __asm__("r12") = name; \
224 register long __r5 __asm__("r5") = (long)(arg1); \
225 __asm__ __volatile__( "brki r14,8; nop;" \
226 : "=r"(__ret) \
227 : "r"(__r5), "r"(__r12) \
228 : SYSCALL_CLOBBERS_1 ); __ret; \
229 })
230
231# define inline_syscall2(name,arg1,arg2) \
232 ({ \
233 register long __ret __asm__("r3"); \
234 register long __r12 __asm__("r12") = name; \
235 register long __r5 __asm__("r5") = (long)(arg1); \
236 register long __r6 __asm__("r6") = (long)(arg2); \
237 __asm__ __volatile__( "brki r14,8; nop;" \
238 : "=r"(__ret) \
239 : "r"(__r5), "r"(__r6), "r"(__r12) \
240 : SYSCALL_CLOBBERS_2 ); __ret; \
241 })
242
243
244# define inline_syscall3(name,arg1,arg2,arg3) \
245 ({ \
246 register long __ret __asm__("r3"); \
247 register long __r12 __asm__("r12") = name; \
248 register long __r5 __asm__("r5") = (long)(arg1); \
249 register long __r6 __asm__("r6") = (long)(arg2); \
250 register long __r7 __asm__("r7") = (long)(arg3); \
251 __asm__ __volatile__( "brki r14,8; nop;" \
252 : "=r"(__ret) \
253 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r12) \
254 : SYSCALL_CLOBBERS_3 ); __ret; \
255 })
256
257
258# define inline_syscall4(name,arg1,arg2,arg3,arg4) \
259 ({ \
260 register long __ret __asm__("r3"); \
261 register long __r12 __asm__("r12") = name; \
262 register long __r5 __asm__("r5") = (long)(arg1); \
263 register long __r6 __asm__("r6") = (long)(arg2); \
264 register long __r7 __asm__("r7") = (long)(arg3); \
265 register long __r8 __asm__("r8") = (long)(arg4); \
266 __asm__ __volatile__( "brki r14,8; nop;" \
267 : "=r"(__ret) \
268 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r12) \
269 : SYSCALL_CLOBBERS_4 ); __ret; \
270 })
271
272
273# define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
274 ({ \
275 register long __ret __asm__("r3"); \
276 register long __r12 __asm__("r12") = name; \
277 register long __r5 __asm__("r5") = (long)(arg1); \
278 register long __r6 __asm__("r6") = (long)(arg2); \
279 register long __r7 __asm__("r7") = (long)(arg3); \
280 register long __r8 __asm__("r8") = (long)(arg4); \
281 register long __r9 __asm__("r9") = (long)(arg5); \
282 __asm__ __volatile__( "brki r14,8; nop;" \
283 : "=r"(__ret) \
284 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r12) \
285 : SYSCALL_CLOBBERS_5 ); __ret; \
286 })
287
288
289# define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
290 ({ \
291 register long __ret __asm__("r3"); \
292 register long __r12 __asm__("r12") = name; \
293 register long __r5 __asm__("r5") = (long)(arg1); \
294 register long __r6 __asm__("r6") = (long)(arg2); \
295 register long __r7 __asm__("r7") = (long)(arg3); \
296 register long __r8 __asm__("r8") = (long)(arg4); \
297 register long __r9 __asm__("r9") = (long)(arg5); \
298 register long __r10 __asm__("r10") = (long)(arg6); \
299 __asm__ __volatile__( "brki r14,8; nop;" \
300 : "=r"(__ret) \
301 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r10), \
302 "r"(__r12) \
303 : SYSCALL_CLOBBERS_6 ); __ret; \
304 })
305
306
307/* Pointer mangling is not yet supported for Microblaze. */
308# define PTR_MANGLE(var) (void) (var)
309# define PTR_DEMANGLE(var) (void) (var)
310
311# define SINGLE_THREAD_BY_GLOBAL 1
312
313#endif /* not __ASSEMBLER__ */
314
315#endif /* _LINUX_MICROBLAZE_SYSDEP_H */
libc/glibc/sysdeps/unix/sysv/linux/mips/asm/sgidefs.h created+45
...@@ -0,0 +1,45 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 1996, 1999, 2001 Ralf Baechle
8 * Copyright (C) 1999 Silicon Graphics, Inc.
9 * Copyright (C) 2001 MIPS Technologies, Inc.
10 */
11#ifndef __ASM_SGIDEFS_H
12#define __ASM_SGIDEFS_H
13
14/*
15 * Using a Linux compiler for building Linux seems logic but not to
16 * everybody.
17 */
18#ifndef __linux__
19#error Use a Linux compiler or give up.
20#endif
21
22/*
23 * Definitions for the ISA levels
24 *
25 * With the introduction of MIPS32 / MIPS64 instruction sets definitions
26 * MIPS ISAs are no longer subsets of each other. Therefore comparisons
27 * on these symbols except with == may result in unexpected results and
28 * are forbidden!
29 */
30#define _MIPS_ISA_MIPS1 1
31#define _MIPS_ISA_MIPS2 2
32#define _MIPS_ISA_MIPS3 3
33#define _MIPS_ISA_MIPS4 4
34#define _MIPS_ISA_MIPS5 5
35#define _MIPS_ISA_MIPS32 6
36#define _MIPS_ISA_MIPS64 7
37
38/*
39 * Subprogram calling convention
40 */
41#define _MIPS_SIM_ABI32 1
42#define _MIPS_SIM_NABI32 2
43#define _MIPS_SIM_ABI64 3
44
45#endif /* __ASM_SGIDEFS_H */
libc/glibc/sysdeps/unix/sysv/linux/mips/asm/unistd.h created+1101
...@@ -0,0 +1,1101 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 *
10 * Changed system calls macros _syscall5 - _syscall7 to push args 5 to 7 onto
11 * the stack. Robin Farine for ACN S.A, Copyright (C) 1996 by ACN S.A
12 */
13#ifndef _UAPI_ASM_UNISTD_H
14#define _UAPI_ASM_UNISTD_H
15
16#include <asm/sgidefs.h>
17
18#if _MIPS_SIM == _MIPS_SIM_ABI32
19
20/*
21 * Linux o32 style syscalls are in the range from 4000 to 4999.
22 */
23#define __NR_Linux 4000
24#define __NR_syscall (__NR_Linux + 0)
25#define __NR_exit (__NR_Linux + 1)
26#define __NR_fork (__NR_Linux + 2)
27#define __NR_read (__NR_Linux + 3)
28#define __NR_write (__NR_Linux + 4)
29#define __NR_open (__NR_Linux + 5)
30#define __NR_close (__NR_Linux + 6)
31#define __NR_waitpid (__NR_Linux + 7)
32#define __NR_creat (__NR_Linux + 8)
33#define __NR_link (__NR_Linux + 9)
34#define __NR_unlink (__NR_Linux + 10)
35#define __NR_execve (__NR_Linux + 11)
36#define __NR_chdir (__NR_Linux + 12)
37#define __NR_time (__NR_Linux + 13)
38#define __NR_mknod (__NR_Linux + 14)
39#define __NR_chmod (__NR_Linux + 15)
40#define __NR_lchown (__NR_Linux + 16)
41#define __NR_break (__NR_Linux + 17)
42#define __NR_unused18 (__NR_Linux + 18)
43#define __NR_lseek (__NR_Linux + 19)
44#define __NR_getpid (__NR_Linux + 20)
45#define __NR_mount (__NR_Linux + 21)
46#define __NR_umount (__NR_Linux + 22)
47#define __NR_setuid (__NR_Linux + 23)
48#define __NR_getuid (__NR_Linux + 24)
49#define __NR_stime (__NR_Linux + 25)
50#define __NR_ptrace (__NR_Linux + 26)
51#define __NR_alarm (__NR_Linux + 27)
52#define __NR_unused28 (__NR_Linux + 28)
53#define __NR_pause (__NR_Linux + 29)
54#define __NR_utime (__NR_Linux + 30)
55#define __NR_stty (__NR_Linux + 31)
56#define __NR_gtty (__NR_Linux + 32)
57#define __NR_access (__NR_Linux + 33)
58#define __NR_nice (__NR_Linux + 34)
59#define __NR_ftime (__NR_Linux + 35)
60#define __NR_sync (__NR_Linux + 36)
61#define __NR_kill (__NR_Linux + 37)
62#define __NR_rename (__NR_Linux + 38)
63#define __NR_mkdir (__NR_Linux + 39)
64#define __NR_rmdir (__NR_Linux + 40)
65#define __NR_dup (__NR_Linux + 41)
66#define __NR_pipe (__NR_Linux + 42)
67#define __NR_times (__NR_Linux + 43)
68#define __NR_prof (__NR_Linux + 44)
69#define __NR_brk (__NR_Linux + 45)
70#define __NR_setgid (__NR_Linux + 46)
71#define __NR_getgid (__NR_Linux + 47)
72#define __NR_signal (__NR_Linux + 48)
73#define __NR_geteuid (__NR_Linux + 49)
74#define __NR_getegid (__NR_Linux + 50)
75#define __NR_acct (__NR_Linux + 51)
76#define __NR_umount2 (__NR_Linux + 52)
77#define __NR_lock (__NR_Linux + 53)
78#define __NR_ioctl (__NR_Linux + 54)
79#define __NR_fcntl (__NR_Linux + 55)
80#define __NR_mpx (__NR_Linux + 56)
81#define __NR_setpgid (__NR_Linux + 57)
82#define __NR_ulimit (__NR_Linux + 58)
83#define __NR_unused59 (__NR_Linux + 59)
84#define __NR_umask (__NR_Linux + 60)
85#define __NR_chroot (__NR_Linux + 61)
86#define __NR_ustat (__NR_Linux + 62)
87#define __NR_dup2 (__NR_Linux + 63)
88#define __NR_getppid (__NR_Linux + 64)
89#define __NR_getpgrp (__NR_Linux + 65)
90#define __NR_setsid (__NR_Linux + 66)
91#define __NR_sigaction (__NR_Linux + 67)
92#define __NR_sgetmask (__NR_Linux + 68)
93#define __NR_ssetmask (__NR_Linux + 69)
94#define __NR_setreuid (__NR_Linux + 70)
95#define __NR_setregid (__NR_Linux + 71)
96#define __NR_sigsuspend (__NR_Linux + 72)
97#define __NR_sigpending (__NR_Linux + 73)
98#define __NR_sethostname (__NR_Linux + 74)
99#define __NR_setrlimit (__NR_Linux + 75)
100#define __NR_getrlimit (__NR_Linux + 76)
101#define __NR_getrusage (__NR_Linux + 77)
102#define __NR_gettimeofday (__NR_Linux + 78)
103#define __NR_settimeofday (__NR_Linux + 79)
104#define __NR_getgroups (__NR_Linux + 80)
105#define __NR_setgroups (__NR_Linux + 81)
106#define __NR_reserved82 (__NR_Linux + 82)
107#define __NR_symlink (__NR_Linux + 83)
108#define __NR_unused84 (__NR_Linux + 84)
109#define __NR_readlink (__NR_Linux + 85)
110#define __NR_uselib (__NR_Linux + 86)
111#define __NR_swapon (__NR_Linux + 87)
112#define __NR_reboot (__NR_Linux + 88)
113#define __NR_readdir (__NR_Linux + 89)
114#define __NR_mmap (__NR_Linux + 90)
115#define __NR_munmap (__NR_Linux + 91)
116#define __NR_truncate (__NR_Linux + 92)
117#define __NR_ftruncate (__NR_Linux + 93)
118#define __NR_fchmod (__NR_Linux + 94)
119#define __NR_fchown (__NR_Linux + 95)
120#define __NR_getpriority (__NR_Linux + 96)
121#define __NR_setpriority (__NR_Linux + 97)
122#define __NR_profil (__NR_Linux + 98)
123#define __NR_statfs (__NR_Linux + 99)
124#define __NR_fstatfs (__NR_Linux + 100)
125#define __NR_ioperm (__NR_Linux + 101)
126#define __NR_socketcall (__NR_Linux + 102)
127#define __NR_syslog (__NR_Linux + 103)
128#define __NR_setitimer (__NR_Linux + 104)
129#define __NR_getitimer (__NR_Linux + 105)
130#define __NR_stat (__NR_Linux + 106)
131#define __NR_lstat (__NR_Linux + 107)
132#define __NR_fstat (__NR_Linux + 108)
133#define __NR_unused109 (__NR_Linux + 109)
134#define __NR_iopl (__NR_Linux + 110)
135#define __NR_vhangup (__NR_Linux + 111)
136#define __NR_idle (__NR_Linux + 112)
137#define __NR_vm86 (__NR_Linux + 113)
138#define __NR_wait4 (__NR_Linux + 114)
139#define __NR_swapoff (__NR_Linux + 115)
140#define __NR_sysinfo (__NR_Linux + 116)
141#define __NR_ipc (__NR_Linux + 117)
142#define __NR_fsync (__NR_Linux + 118)
143#define __NR_sigreturn (__NR_Linux + 119)
144#define __NR_clone (__NR_Linux + 120)
145#define __NR_setdomainname (__NR_Linux + 121)
146#define __NR_uname (__NR_Linux + 122)
147#define __NR_modify_ldt (__NR_Linux + 123)
148#define __NR_adjtimex (__NR_Linux + 124)
149#define __NR_mprotect (__NR_Linux + 125)
150#define __NR_sigprocmask (__NR_Linux + 126)
151#define __NR_create_module (__NR_Linux + 127)
152#define __NR_init_module (__NR_Linux + 128)
153#define __NR_delete_module (__NR_Linux + 129)
154#define __NR_get_kernel_syms (__NR_Linux + 130)
155#define __NR_quotactl (__NR_Linux + 131)
156#define __NR_getpgid (__NR_Linux + 132)
157#define __NR_fchdir (__NR_Linux + 133)
158#define __NR_bdflush (__NR_Linux + 134)
159#define __NR_sysfs (__NR_Linux + 135)
160#define __NR_personality (__NR_Linux + 136)
161#define __NR_afs_syscall (__NR_Linux + 137) /* Syscall for Andrew File System */
162#define __NR_setfsuid (__NR_Linux + 138)
163#define __NR_setfsgid (__NR_Linux + 139)
164#define __NR__llseek (__NR_Linux + 140)
165#define __NR_getdents (__NR_Linux + 141)
166#define __NR__newselect (__NR_Linux + 142)
167#define __NR_flock (__NR_Linux + 143)
168#define __NR_msync (__NR_Linux + 144)
169#define __NR_readv (__NR_Linux + 145)
170#define __NR_writev (__NR_Linux + 146)
171#define __NR_cacheflush (__NR_Linux + 147)
172#define __NR_cachectl (__NR_Linux + 148)
173#define __NR_sysmips (__NR_Linux + 149)
174#define __NR_unused150 (__NR_Linux + 150)
175#define __NR_getsid (__NR_Linux + 151)
176#define __NR_fdatasync (__NR_Linux + 152)
177#define __NR__sysctl (__NR_Linux + 153)
178#define __NR_mlock (__NR_Linux + 154)
179#define __NR_munlock (__NR_Linux + 155)
180#define __NR_mlockall (__NR_Linux + 156)
181#define __NR_munlockall (__NR_Linux + 157)
182#define __NR_sched_setparam (__NR_Linux + 158)
183#define __NR_sched_getparam (__NR_Linux + 159)
184#define __NR_sched_setscheduler (__NR_Linux + 160)
185#define __NR_sched_getscheduler (__NR_Linux + 161)
186#define __NR_sched_yield (__NR_Linux + 162)
187#define __NR_sched_get_priority_max (__NR_Linux + 163)
188#define __NR_sched_get_priority_min (__NR_Linux + 164)
189#define __NR_sched_rr_get_interval (__NR_Linux + 165)
190#define __NR_nanosleep (__NR_Linux + 166)
191#define __NR_mremap (__NR_Linux + 167)
192#define __NR_accept (__NR_Linux + 168)
193#define __NR_bind (__NR_Linux + 169)
194#define __NR_connect (__NR_Linux + 170)
195#define __NR_getpeername (__NR_Linux + 171)
196#define __NR_getsockname (__NR_Linux + 172)
197#define __NR_getsockopt (__NR_Linux + 173)
198#define __NR_listen (__NR_Linux + 174)
199#define __NR_recv (__NR_Linux + 175)
200#define __NR_recvfrom (__NR_Linux + 176)
201#define __NR_recvmsg (__NR_Linux + 177)
202#define __NR_send (__NR_Linux + 178)
203#define __NR_sendmsg (__NR_Linux + 179)
204#define __NR_sendto (__NR_Linux + 180)
205#define __NR_setsockopt (__NR_Linux + 181)
206#define __NR_shutdown (__NR_Linux + 182)
207#define __NR_socket (__NR_Linux + 183)
208#define __NR_socketpair (__NR_Linux + 184)
209#define __NR_setresuid (__NR_Linux + 185)
210#define __NR_getresuid (__NR_Linux + 186)
211#define __NR_query_module (__NR_Linux + 187)
212#define __NR_poll (__NR_Linux + 188)
213#define __NR_nfsservctl (__NR_Linux + 189)
214#define __NR_setresgid (__NR_Linux + 190)
215#define __NR_getresgid (__NR_Linux + 191)
216#define __NR_prctl (__NR_Linux + 192)
217#define __NR_rt_sigreturn (__NR_Linux + 193)
218#define __NR_rt_sigaction (__NR_Linux + 194)
219#define __NR_rt_sigprocmask (__NR_Linux + 195)
220#define __NR_rt_sigpending (__NR_Linux + 196)
221#define __NR_rt_sigtimedwait (__NR_Linux + 197)
222#define __NR_rt_sigqueueinfo (__NR_Linux + 198)
223#define __NR_rt_sigsuspend (__NR_Linux + 199)
224#define __NR_pread64 (__NR_Linux + 200)
225#define __NR_pwrite64 (__NR_Linux + 201)
226#define __NR_chown (__NR_Linux + 202)
227#define __NR_getcwd (__NR_Linux + 203)
228#define __NR_capget (__NR_Linux + 204)
229#define __NR_capset (__NR_Linux + 205)
230#define __NR_sigaltstack (__NR_Linux + 206)
231#define __NR_sendfile (__NR_Linux + 207)
232#define __NR_getpmsg (__NR_Linux + 208)
233#define __NR_putpmsg (__NR_Linux + 209)
234#define __NR_mmap2 (__NR_Linux + 210)
235#define __NR_truncate64 (__NR_Linux + 211)
236#define __NR_ftruncate64 (__NR_Linux + 212)
237#define __NR_stat64 (__NR_Linux + 213)
238#define __NR_lstat64 (__NR_Linux + 214)
239#define __NR_fstat64 (__NR_Linux + 215)
240#define __NR_pivot_root (__NR_Linux + 216)
241#define __NR_mincore (__NR_Linux + 217)
242#define __NR_madvise (__NR_Linux + 218)
243#define __NR_getdents64 (__NR_Linux + 219)
244#define __NR_fcntl64 (__NR_Linux + 220)
245#define __NR_reserved221 (__NR_Linux + 221)
246#define __NR_gettid (__NR_Linux + 222)
247#define __NR_readahead (__NR_Linux + 223)
248#define __NR_setxattr (__NR_Linux + 224)
249#define __NR_lsetxattr (__NR_Linux + 225)
250#define __NR_fsetxattr (__NR_Linux + 226)
251#define __NR_getxattr (__NR_Linux + 227)
252#define __NR_lgetxattr (__NR_Linux + 228)
253#define __NR_fgetxattr (__NR_Linux + 229)
254#define __NR_listxattr (__NR_Linux + 230)
255#define __NR_llistxattr (__NR_Linux + 231)
256#define __NR_flistxattr (__NR_Linux + 232)
257#define __NR_removexattr (__NR_Linux + 233)
258#define __NR_lremovexattr (__NR_Linux + 234)
259#define __NR_fremovexattr (__NR_Linux + 235)
260#define __NR_tkill (__NR_Linux + 236)
261#define __NR_sendfile64 (__NR_Linux + 237)
262#define __NR_futex (__NR_Linux + 238)
263#define __NR_sched_setaffinity (__NR_Linux + 239)
264#define __NR_sched_getaffinity (__NR_Linux + 240)
265#define __NR_io_setup (__NR_Linux + 241)
266#define __NR_io_destroy (__NR_Linux + 242)
267#define __NR_io_getevents (__NR_Linux + 243)
268#define __NR_io_submit (__NR_Linux + 244)
269#define __NR_io_cancel (__NR_Linux + 245)
270#define __NR_exit_group (__NR_Linux + 246)
271#define __NR_lookup_dcookie (__NR_Linux + 247)
272#define __NR_epoll_create (__NR_Linux + 248)
273#define __NR_epoll_ctl (__NR_Linux + 249)
274#define __NR_epoll_wait (__NR_Linux + 250)
275#define __NR_remap_file_pages (__NR_Linux + 251)
276#define __NR_set_tid_address (__NR_Linux + 252)
277#define __NR_restart_syscall (__NR_Linux + 253)
278#define __NR_fadvise64 (__NR_Linux + 254)
279#define __NR_statfs64 (__NR_Linux + 255)
280#define __NR_fstatfs64 (__NR_Linux + 256)
281#define __NR_timer_create (__NR_Linux + 257)
282#define __NR_timer_settime (__NR_Linux + 258)
283#define __NR_timer_gettime (__NR_Linux + 259)
284#define __NR_timer_getoverrun (__NR_Linux + 260)
285#define __NR_timer_delete (__NR_Linux + 261)
286#define __NR_clock_settime (__NR_Linux + 262)
287#define __NR_clock_gettime (__NR_Linux + 263)
288#define __NR_clock_getres (__NR_Linux + 264)
289#define __NR_clock_nanosleep (__NR_Linux + 265)
290#define __NR_tgkill (__NR_Linux + 266)
291#define __NR_utimes (__NR_Linux + 267)
292#define __NR_mbind (__NR_Linux + 268)
293#define __NR_get_mempolicy (__NR_Linux + 269)
294#define __NR_set_mempolicy (__NR_Linux + 270)
295#define __NR_mq_open (__NR_Linux + 271)
296#define __NR_mq_unlink (__NR_Linux + 272)
297#define __NR_mq_timedsend (__NR_Linux + 273)
298#define __NR_mq_timedreceive (__NR_Linux + 274)
299#define __NR_mq_notify (__NR_Linux + 275)
300#define __NR_mq_getsetattr (__NR_Linux + 276)
301#define __NR_vserver (__NR_Linux + 277)
302#define __NR_waitid (__NR_Linux + 278)
303/* #define __NR_sys_setaltroot (__NR_Linux + 279) */
304#define __NR_add_key (__NR_Linux + 280)
305#define __NR_request_key (__NR_Linux + 281)
306#define __NR_keyctl (__NR_Linux + 282)
307#define __NR_set_thread_area (__NR_Linux + 283)
308#define __NR_inotify_init (__NR_Linux + 284)
309#define __NR_inotify_add_watch (__NR_Linux + 285)
310#define __NR_inotify_rm_watch (__NR_Linux + 286)
311#define __NR_migrate_pages (__NR_Linux + 287)
312#define __NR_openat (__NR_Linux + 288)
313#define __NR_mkdirat (__NR_Linux + 289)
314#define __NR_mknodat (__NR_Linux + 290)
315#define __NR_fchownat (__NR_Linux + 291)
316#define __NR_futimesat (__NR_Linux + 292)
317#define __NR_fstatat64 (__NR_Linux + 293)
318#define __NR_unlinkat (__NR_Linux + 294)
319#define __NR_renameat (__NR_Linux + 295)
320#define __NR_linkat (__NR_Linux + 296)
321#define __NR_symlinkat (__NR_Linux + 297)
322#define __NR_readlinkat (__NR_Linux + 298)
323#define __NR_fchmodat (__NR_Linux + 299)
324#define __NR_faccessat (__NR_Linux + 300)
325#define __NR_pselect6 (__NR_Linux + 301)
326#define __NR_ppoll (__NR_Linux + 302)
327#define __NR_unshare (__NR_Linux + 303)
328#define __NR_splice (__NR_Linux + 304)
329#define __NR_sync_file_range (__NR_Linux + 305)
330#define __NR_tee (__NR_Linux + 306)
331#define __NR_vmsplice (__NR_Linux + 307)
332#define __NR_move_pages (__NR_Linux + 308)
333#define __NR_set_robust_list (__NR_Linux + 309)
334#define __NR_get_robust_list (__NR_Linux + 310)
335#define __NR_kexec_load (__NR_Linux + 311)
336#define __NR_getcpu (__NR_Linux + 312)
337#define __NR_epoll_pwait (__NR_Linux + 313)
338#define __NR_ioprio_set (__NR_Linux + 314)
339#define __NR_ioprio_get (__NR_Linux + 315)
340#define __NR_utimensat (__NR_Linux + 316)
341#define __NR_signalfd (__NR_Linux + 317)
342#define __NR_timerfd (__NR_Linux + 318)
343#define __NR_eventfd (__NR_Linux + 319)
344#define __NR_fallocate (__NR_Linux + 320)
345#define __NR_timerfd_create (__NR_Linux + 321)
346#define __NR_timerfd_gettime (__NR_Linux + 322)
347#define __NR_timerfd_settime (__NR_Linux + 323)
348#define __NR_signalfd4 (__NR_Linux + 324)
349#define __NR_eventfd2 (__NR_Linux + 325)
350#define __NR_epoll_create1 (__NR_Linux + 326)
351#define __NR_dup3 (__NR_Linux + 327)
352#define __NR_pipe2 (__NR_Linux + 328)
353#define __NR_inotify_init1 (__NR_Linux + 329)
354#define __NR_preadv (__NR_Linux + 330)
355#define __NR_pwritev (__NR_Linux + 331)
356#define __NR_rt_tgsigqueueinfo (__NR_Linux + 332)
357#define __NR_perf_event_open (__NR_Linux + 333)
358#define __NR_accept4 (__NR_Linux + 334)
359#define __NR_recvmmsg (__NR_Linux + 335)
360#define __NR_fanotify_init (__NR_Linux + 336)
361#define __NR_fanotify_mark (__NR_Linux + 337)
362#define __NR_prlimit64 (__NR_Linux + 338)
363#define __NR_name_to_handle_at (__NR_Linux + 339)
364#define __NR_open_by_handle_at (__NR_Linux + 340)
365#define __NR_clock_adjtime (__NR_Linux + 341)
366#define __NR_syncfs (__NR_Linux + 342)
367#define __NR_sendmmsg (__NR_Linux + 343)
368#define __NR_setns (__NR_Linux + 344)
369#define __NR_process_vm_readv (__NR_Linux + 345)
370#define __NR_process_vm_writev (__NR_Linux + 346)
371#define __NR_kcmp (__NR_Linux + 347)
372#define __NR_finit_module (__NR_Linux + 348)
373#define __NR_sched_setattr (__NR_Linux + 349)
374#define __NR_sched_getattr (__NR_Linux + 350)
375#define __NR_renameat2 (__NR_Linux + 351)
376#define __NR_seccomp (__NR_Linux + 352)
377#define __NR_getrandom (__NR_Linux + 353)
378#define __NR_memfd_create (__NR_Linux + 354)
379#define __NR_bpf (__NR_Linux + 355)
380#define __NR_execveat (__NR_Linux + 356)
381#define __NR_userfaultfd (__NR_Linux + 357)
382#define __NR_membarrier (__NR_Linux + 358)
383#define __NR_mlock2 (__NR_Linux + 359)
384#define __NR_copy_file_range (__NR_Linux + 360)
385#define __NR_preadv2 (__NR_Linux + 361)
386#define __NR_pwritev2 (__NR_Linux + 362)
387#define __NR_pkey_mprotect (__NR_Linux + 363)
388#define __NR_pkey_alloc (__NR_Linux + 364)
389#define __NR_pkey_free (__NR_Linux + 365)
390#define __NR_statx (__NR_Linux + 366)
391#define __NR_rseq (__NR_Linux + 367)
392#define __NR_io_pgetevents (__NR_Linux + 368)
393
394
395/*
396 * Offset of the last Linux o32 flavoured syscall
397 */
398#define __NR_Linux_syscalls 368
399
400#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
401
402#define __NR_O32_Linux 4000
403#define __NR_O32_Linux_syscalls 368
404
405#if _MIPS_SIM == _MIPS_SIM_ABI64
406
407/*
408 * Linux 64-bit syscalls are in the range from 5000 to 5999.
409 */
410#define __NR_Linux 5000
411#define __NR_read (__NR_Linux + 0)
412#define __NR_write (__NR_Linux + 1)
413#define __NR_open (__NR_Linux + 2)
414#define __NR_close (__NR_Linux + 3)
415#define __NR_stat (__NR_Linux + 4)
416#define __NR_fstat (__NR_Linux + 5)
417#define __NR_lstat (__NR_Linux + 6)
418#define __NR_poll (__NR_Linux + 7)
419#define __NR_lseek (__NR_Linux + 8)
420#define __NR_mmap (__NR_Linux + 9)
421#define __NR_mprotect (__NR_Linux + 10)
422#define __NR_munmap (__NR_Linux + 11)
423#define __NR_brk (__NR_Linux + 12)
424#define __NR_rt_sigaction (__NR_Linux + 13)
425#define __NR_rt_sigprocmask (__NR_Linux + 14)
426#define __NR_ioctl (__NR_Linux + 15)
427#define __NR_pread64 (__NR_Linux + 16)
428#define __NR_pwrite64 (__NR_Linux + 17)
429#define __NR_readv (__NR_Linux + 18)
430#define __NR_writev (__NR_Linux + 19)
431#define __NR_access (__NR_Linux + 20)
432#define __NR_pipe (__NR_Linux + 21)
433#define __NR__newselect (__NR_Linux + 22)
434#define __NR_sched_yield (__NR_Linux + 23)
435#define __NR_mremap (__NR_Linux + 24)
436#define __NR_msync (__NR_Linux + 25)
437#define __NR_mincore (__NR_Linux + 26)
438#define __NR_madvise (__NR_Linux + 27)
439#define __NR_shmget (__NR_Linux + 28)
440#define __NR_shmat (__NR_Linux + 29)
441#define __NR_shmctl (__NR_Linux + 30)
442#define __NR_dup (__NR_Linux + 31)
443#define __NR_dup2 (__NR_Linux + 32)
444#define __NR_pause (__NR_Linux + 33)
445#define __NR_nanosleep (__NR_Linux + 34)
446#define __NR_getitimer (__NR_Linux + 35)
447#define __NR_setitimer (__NR_Linux + 36)
448#define __NR_alarm (__NR_Linux + 37)
449#define __NR_getpid (__NR_Linux + 38)
450#define __NR_sendfile (__NR_Linux + 39)
451#define __NR_socket (__NR_Linux + 40)
452#define __NR_connect (__NR_Linux + 41)
453#define __NR_accept (__NR_Linux + 42)
454#define __NR_sendto (__NR_Linux + 43)
455#define __NR_recvfrom (__NR_Linux + 44)
456#define __NR_sendmsg (__NR_Linux + 45)
457#define __NR_recvmsg (__NR_Linux + 46)
458#define __NR_shutdown (__NR_Linux + 47)
459#define __NR_bind (__NR_Linux + 48)
460#define __NR_listen (__NR_Linux + 49)
461#define __NR_getsockname (__NR_Linux + 50)
462#define __NR_getpeername (__NR_Linux + 51)
463#define __NR_socketpair (__NR_Linux + 52)
464#define __NR_setsockopt (__NR_Linux + 53)
465#define __NR_getsockopt (__NR_Linux + 54)
466#define __NR_clone (__NR_Linux + 55)
467#define __NR_fork (__NR_Linux + 56)
468#define __NR_execve (__NR_Linux + 57)
469#define __NR_exit (__NR_Linux + 58)
470#define __NR_wait4 (__NR_Linux + 59)
471#define __NR_kill (__NR_Linux + 60)
472#define __NR_uname (__NR_Linux + 61)
473#define __NR_semget (__NR_Linux + 62)
474#define __NR_semop (__NR_Linux + 63)
475#define __NR_semctl (__NR_Linux + 64)
476#define __NR_shmdt (__NR_Linux + 65)
477#define __NR_msgget (__NR_Linux + 66)
478#define __NR_msgsnd (__NR_Linux + 67)
479#define __NR_msgrcv (__NR_Linux + 68)
480#define __NR_msgctl (__NR_Linux + 69)
481#define __NR_fcntl (__NR_Linux + 70)
482#define __NR_flock (__NR_Linux + 71)
483#define __NR_fsync (__NR_Linux + 72)
484#define __NR_fdatasync (__NR_Linux + 73)
485#define __NR_truncate (__NR_Linux + 74)
486#define __NR_ftruncate (__NR_Linux + 75)
487#define __NR_getdents (__NR_Linux + 76)
488#define __NR_getcwd (__NR_Linux + 77)
489#define __NR_chdir (__NR_Linux + 78)
490#define __NR_fchdir (__NR_Linux + 79)
491#define __NR_rename (__NR_Linux + 80)
492#define __NR_mkdir (__NR_Linux + 81)
493#define __NR_rmdir (__NR_Linux + 82)
494#define __NR_creat (__NR_Linux + 83)
495#define __NR_link (__NR_Linux + 84)
496#define __NR_unlink (__NR_Linux + 85)
497#define __NR_symlink (__NR_Linux + 86)
498#define __NR_readlink (__NR_Linux + 87)
499#define __NR_chmod (__NR_Linux + 88)
500#define __NR_fchmod (__NR_Linux + 89)
501#define __NR_chown (__NR_Linux + 90)
502#define __NR_fchown (__NR_Linux + 91)
503#define __NR_lchown (__NR_Linux + 92)
504#define __NR_umask (__NR_Linux + 93)
505#define __NR_gettimeofday (__NR_Linux + 94)
506#define __NR_getrlimit (__NR_Linux + 95)
507#define __NR_getrusage (__NR_Linux + 96)
508#define __NR_sysinfo (__NR_Linux + 97)
509#define __NR_times (__NR_Linux + 98)
510#define __NR_ptrace (__NR_Linux + 99)
511#define __NR_getuid (__NR_Linux + 100)
512#define __NR_syslog (__NR_Linux + 101)
513#define __NR_getgid (__NR_Linux + 102)
514#define __NR_setuid (__NR_Linux + 103)
515#define __NR_setgid (__NR_Linux + 104)
516#define __NR_geteuid (__NR_Linux + 105)
517#define __NR_getegid (__NR_Linux + 106)
518#define __NR_setpgid (__NR_Linux + 107)
519#define __NR_getppid (__NR_Linux + 108)
520#define __NR_getpgrp (__NR_Linux + 109)
521#define __NR_setsid (__NR_Linux + 110)
522#define __NR_setreuid (__NR_Linux + 111)
523#define __NR_setregid (__NR_Linux + 112)
524#define __NR_getgroups (__NR_Linux + 113)
525#define __NR_setgroups (__NR_Linux + 114)
526#define __NR_setresuid (__NR_Linux + 115)
527#define __NR_getresuid (__NR_Linux + 116)
528#define __NR_setresgid (__NR_Linux + 117)
529#define __NR_getresgid (__NR_Linux + 118)
530#define __NR_getpgid (__NR_Linux + 119)
531#define __NR_setfsuid (__NR_Linux + 120)
532#define __NR_setfsgid (__NR_Linux + 121)
533#define __NR_getsid (__NR_Linux + 122)
534#define __NR_capget (__NR_Linux + 123)
535#define __NR_capset (__NR_Linux + 124)
536#define __NR_rt_sigpending (__NR_Linux + 125)
537#define __NR_rt_sigtimedwait (__NR_Linux + 126)
538#define __NR_rt_sigqueueinfo (__NR_Linux + 127)
539#define __NR_rt_sigsuspend (__NR_Linux + 128)
540#define __NR_sigaltstack (__NR_Linux + 129)
541#define __NR_utime (__NR_Linux + 130)
542#define __NR_mknod (__NR_Linux + 131)
543#define __NR_personality (__NR_Linux + 132)
544#define __NR_ustat (__NR_Linux + 133)
545#define __NR_statfs (__NR_Linux + 134)
546#define __NR_fstatfs (__NR_Linux + 135)
547#define __NR_sysfs (__NR_Linux + 136)
548#define __NR_getpriority (__NR_Linux + 137)
549#define __NR_setpriority (__NR_Linux + 138)
550#define __NR_sched_setparam (__NR_Linux + 139)
551#define __NR_sched_getparam (__NR_Linux + 140)
552#define __NR_sched_setscheduler (__NR_Linux + 141)
553#define __NR_sched_getscheduler (__NR_Linux + 142)
554#define __NR_sched_get_priority_max (__NR_Linux + 143)
555#define __NR_sched_get_priority_min (__NR_Linux + 144)
556#define __NR_sched_rr_get_interval (__NR_Linux + 145)
557#define __NR_mlock (__NR_Linux + 146)
558#define __NR_munlock (__NR_Linux + 147)
559#define __NR_mlockall (__NR_Linux + 148)
560#define __NR_munlockall (__NR_Linux + 149)
561#define __NR_vhangup (__NR_Linux + 150)
562#define __NR_pivot_root (__NR_Linux + 151)
563#define __NR__sysctl (__NR_Linux + 152)
564#define __NR_prctl (__NR_Linux + 153)
565#define __NR_adjtimex (__NR_Linux + 154)
566#define __NR_setrlimit (__NR_Linux + 155)
567#define __NR_chroot (__NR_Linux + 156)
568#define __NR_sync (__NR_Linux + 157)
569#define __NR_acct (__NR_Linux + 158)
570#define __NR_settimeofday (__NR_Linux + 159)
571#define __NR_mount (__NR_Linux + 160)
572#define __NR_umount2 (__NR_Linux + 161)
573#define __NR_swapon (__NR_Linux + 162)
574#define __NR_swapoff (__NR_Linux + 163)
575#define __NR_reboot (__NR_Linux + 164)
576#define __NR_sethostname (__NR_Linux + 165)
577#define __NR_setdomainname (__NR_Linux + 166)
578#define __NR_create_module (__NR_Linux + 167)
579#define __NR_init_module (__NR_Linux + 168)
580#define __NR_delete_module (__NR_Linux + 169)
581#define __NR_get_kernel_syms (__NR_Linux + 170)
582#define __NR_query_module (__NR_Linux + 171)
583#define __NR_quotactl (__NR_Linux + 172)
584#define __NR_nfsservctl (__NR_Linux + 173)
585#define __NR_getpmsg (__NR_Linux + 174)
586#define __NR_putpmsg (__NR_Linux + 175)
587#define __NR_afs_syscall (__NR_Linux + 176)
588#define __NR_reserved177 (__NR_Linux + 177)
589#define __NR_gettid (__NR_Linux + 178)
590#define __NR_readahead (__NR_Linux + 179)
591#define __NR_setxattr (__NR_Linux + 180)
592#define __NR_lsetxattr (__NR_Linux + 181)
593#define __NR_fsetxattr (__NR_Linux + 182)
594#define __NR_getxattr (__NR_Linux + 183)
595#define __NR_lgetxattr (__NR_Linux + 184)
596#define __NR_fgetxattr (__NR_Linux + 185)
597#define __NR_listxattr (__NR_Linux + 186)
598#define __NR_llistxattr (__NR_Linux + 187)
599#define __NR_flistxattr (__NR_Linux + 188)
600#define __NR_removexattr (__NR_Linux + 189)
601#define __NR_lremovexattr (__NR_Linux + 190)
602#define __NR_fremovexattr (__NR_Linux + 191)
603#define __NR_tkill (__NR_Linux + 192)
604#define __NR_reserved193 (__NR_Linux + 193)
605#define __NR_futex (__NR_Linux + 194)
606#define __NR_sched_setaffinity (__NR_Linux + 195)
607#define __NR_sched_getaffinity (__NR_Linux + 196)
608#define __NR_cacheflush (__NR_Linux + 197)
609#define __NR_cachectl (__NR_Linux + 198)
610#define __NR_sysmips (__NR_Linux + 199)
611#define __NR_io_setup (__NR_Linux + 200)
612#define __NR_io_destroy (__NR_Linux + 201)
613#define __NR_io_getevents (__NR_Linux + 202)
614#define __NR_io_submit (__NR_Linux + 203)
615#define __NR_io_cancel (__NR_Linux + 204)
616#define __NR_exit_group (__NR_Linux + 205)
617#define __NR_lookup_dcookie (__NR_Linux + 206)
618#define __NR_epoll_create (__NR_Linux + 207)
619#define __NR_epoll_ctl (__NR_Linux + 208)
620#define __NR_epoll_wait (__NR_Linux + 209)
621#define __NR_remap_file_pages (__NR_Linux + 210)
622#define __NR_rt_sigreturn (__NR_Linux + 211)
623#define __NR_set_tid_address (__NR_Linux + 212)
624#define __NR_restart_syscall (__NR_Linux + 213)
625#define __NR_semtimedop (__NR_Linux + 214)
626#define __NR_fadvise64 (__NR_Linux + 215)
627#define __NR_timer_create (__NR_Linux + 216)
628#define __NR_timer_settime (__NR_Linux + 217)
629#define __NR_timer_gettime (__NR_Linux + 218)
630#define __NR_timer_getoverrun (__NR_Linux + 219)
631#define __NR_timer_delete (__NR_Linux + 220)
632#define __NR_clock_settime (__NR_Linux + 221)
633#define __NR_clock_gettime (__NR_Linux + 222)
634#define __NR_clock_getres (__NR_Linux + 223)
635#define __NR_clock_nanosleep (__NR_Linux + 224)
636#define __NR_tgkill (__NR_Linux + 225)
637#define __NR_utimes (__NR_Linux + 226)
638#define __NR_mbind (__NR_Linux + 227)
639#define __NR_get_mempolicy (__NR_Linux + 228)
640#define __NR_set_mempolicy (__NR_Linux + 229)
641#define __NR_mq_open (__NR_Linux + 230)
642#define __NR_mq_unlink (__NR_Linux + 231)
643#define __NR_mq_timedsend (__NR_Linux + 232)
644#define __NR_mq_timedreceive (__NR_Linux + 233)
645#define __NR_mq_notify (__NR_Linux + 234)
646#define __NR_mq_getsetattr (__NR_Linux + 235)
647#define __NR_vserver (__NR_Linux + 236)
648#define __NR_waitid (__NR_Linux + 237)
649/* #define __NR_sys_setaltroot (__NR_Linux + 238) */
650#define __NR_add_key (__NR_Linux + 239)
651#define __NR_request_key (__NR_Linux + 240)
652#define __NR_keyctl (__NR_Linux + 241)
653#define __NR_set_thread_area (__NR_Linux + 242)
654#define __NR_inotify_init (__NR_Linux + 243)
655#define __NR_inotify_add_watch (__NR_Linux + 244)
656#define __NR_inotify_rm_watch (__NR_Linux + 245)
657#define __NR_migrate_pages (__NR_Linux + 246)
658#define __NR_openat (__NR_Linux + 247)
659#define __NR_mkdirat (__NR_Linux + 248)
660#define __NR_mknodat (__NR_Linux + 249)
661#define __NR_fchownat (__NR_Linux + 250)
662#define __NR_futimesat (__NR_Linux + 251)
663#define __NR_newfstatat (__NR_Linux + 252)
664#define __NR_unlinkat (__NR_Linux + 253)
665#define __NR_renameat (__NR_Linux + 254)
666#define __NR_linkat (__NR_Linux + 255)
667#define __NR_symlinkat (__NR_Linux + 256)
668#define __NR_readlinkat (__NR_Linux + 257)
669#define __NR_fchmodat (__NR_Linux + 258)
670#define __NR_faccessat (__NR_Linux + 259)
671#define __NR_pselect6 (__NR_Linux + 260)
672#define __NR_ppoll (__NR_Linux + 261)
673#define __NR_unshare (__NR_Linux + 262)
674#define __NR_splice (__NR_Linux + 263)
675#define __NR_sync_file_range (__NR_Linux + 264)
676#define __NR_tee (__NR_Linux + 265)
677#define __NR_vmsplice (__NR_Linux + 266)
678#define __NR_move_pages (__NR_Linux + 267)
679#define __NR_set_robust_list (__NR_Linux + 268)
680#define __NR_get_robust_list (__NR_Linux + 269)
681#define __NR_kexec_load (__NR_Linux + 270)
682#define __NR_getcpu (__NR_Linux + 271)
683#define __NR_epoll_pwait (__NR_Linux + 272)
684#define __NR_ioprio_set (__NR_Linux + 273)
685#define __NR_ioprio_get (__NR_Linux + 274)
686#define __NR_utimensat (__NR_Linux + 275)
687#define __NR_signalfd (__NR_Linux + 276)
688#define __NR_timerfd (__NR_Linux + 277)
689#define __NR_eventfd (__NR_Linux + 278)
690#define __NR_fallocate (__NR_Linux + 279)
691#define __NR_timerfd_create (__NR_Linux + 280)
692#define __NR_timerfd_gettime (__NR_Linux + 281)
693#define __NR_timerfd_settime (__NR_Linux + 282)
694#define __NR_signalfd4 (__NR_Linux + 283)
695#define __NR_eventfd2 (__NR_Linux + 284)
696#define __NR_epoll_create1 (__NR_Linux + 285)
697#define __NR_dup3 (__NR_Linux + 286)
698#define __NR_pipe2 (__NR_Linux + 287)
699#define __NR_inotify_init1 (__NR_Linux + 288)
700#define __NR_preadv (__NR_Linux + 289)
701#define __NR_pwritev (__NR_Linux + 290)
702#define __NR_rt_tgsigqueueinfo (__NR_Linux + 291)
703#define __NR_perf_event_open (__NR_Linux + 292)
704#define __NR_accept4 (__NR_Linux + 293)
705#define __NR_recvmmsg (__NR_Linux + 294)
706#define __NR_fanotify_init (__NR_Linux + 295)
707#define __NR_fanotify_mark (__NR_Linux + 296)
708#define __NR_prlimit64 (__NR_Linux + 297)
709#define __NR_name_to_handle_at (__NR_Linux + 298)
710#define __NR_open_by_handle_at (__NR_Linux + 299)
711#define __NR_clock_adjtime (__NR_Linux + 300)
712#define __NR_syncfs (__NR_Linux + 301)
713#define __NR_sendmmsg (__NR_Linux + 302)
714#define __NR_setns (__NR_Linux + 303)
715#define __NR_process_vm_readv (__NR_Linux + 304)
716#define __NR_process_vm_writev (__NR_Linux + 305)
717#define __NR_kcmp (__NR_Linux + 306)
718#define __NR_finit_module (__NR_Linux + 307)
719#define __NR_getdents64 (__NR_Linux + 308)
720#define __NR_sched_setattr (__NR_Linux + 309)
721#define __NR_sched_getattr (__NR_Linux + 310)
722#define __NR_renameat2 (__NR_Linux + 311)
723#define __NR_seccomp (__NR_Linux + 312)
724#define __NR_getrandom (__NR_Linux + 313)
725#define __NR_memfd_create (__NR_Linux + 314)
726#define __NR_bpf (__NR_Linux + 315)
727#define __NR_execveat (__NR_Linux + 316)
728#define __NR_userfaultfd (__NR_Linux + 317)
729#define __NR_membarrier (__NR_Linux + 318)
730#define __NR_mlock2 (__NR_Linux + 319)
731#define __NR_copy_file_range (__NR_Linux + 320)
732#define __NR_preadv2 (__NR_Linux + 321)
733#define __NR_pwritev2 (__NR_Linux + 322)
734#define __NR_pkey_mprotect (__NR_Linux + 323)
735#define __NR_pkey_alloc (__NR_Linux + 324)
736#define __NR_pkey_free (__NR_Linux + 325)
737#define __NR_statx (__NR_Linux + 326)
738#define __NR_rseq (__NR_Linux + 327)
739#define __NR_io_pgetevents (__NR_Linux + 328)
740
741/*
742 * Offset of the last Linux 64-bit flavoured syscall
743 */
744#define __NR_Linux_syscalls 328
745
746#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
747
748#define __NR_64_Linux 5000
749#define __NR_64_Linux_syscalls 328
750
751#if _MIPS_SIM == _MIPS_SIM_NABI32
752
753/*
754 * Linux N32 syscalls are in the range from 6000 to 6999.
755 */
756#define __NR_Linux 6000
757#define __NR_read (__NR_Linux + 0)
758#define __NR_write (__NR_Linux + 1)
759#define __NR_open (__NR_Linux + 2)
760#define __NR_close (__NR_Linux + 3)
761#define __NR_stat (__NR_Linux + 4)
762#define __NR_fstat (__NR_Linux + 5)
763#define __NR_lstat (__NR_Linux + 6)
764#define __NR_poll (__NR_Linux + 7)
765#define __NR_lseek (__NR_Linux + 8)
766#define __NR_mmap (__NR_Linux + 9)
767#define __NR_mprotect (__NR_Linux + 10)
768#define __NR_munmap (__NR_Linux + 11)
769#define __NR_brk (__NR_Linux + 12)
770#define __NR_rt_sigaction (__NR_Linux + 13)
771#define __NR_rt_sigprocmask (__NR_Linux + 14)
772#define __NR_ioctl (__NR_Linux + 15)
773#define __NR_pread64 (__NR_Linux + 16)
774#define __NR_pwrite64 (__NR_Linux + 17)
775#define __NR_readv (__NR_Linux + 18)
776#define __NR_writev (__NR_Linux + 19)
777#define __NR_access (__NR_Linux + 20)
778#define __NR_pipe (__NR_Linux + 21)
779#define __NR__newselect (__NR_Linux + 22)
780#define __NR_sched_yield (__NR_Linux + 23)
781#define __NR_mremap (__NR_Linux + 24)
782#define __NR_msync (__NR_Linux + 25)
783#define __NR_mincore (__NR_Linux + 26)
784#define __NR_madvise (__NR_Linux + 27)
785#define __NR_shmget (__NR_Linux + 28)
786#define __NR_shmat (__NR_Linux + 29)
787#define __NR_shmctl (__NR_Linux + 30)
788#define __NR_dup (__NR_Linux + 31)
789#define __NR_dup2 (__NR_Linux + 32)
790#define __NR_pause (__NR_Linux + 33)
791#define __NR_nanosleep (__NR_Linux + 34)
792#define __NR_getitimer (__NR_Linux + 35)
793#define __NR_setitimer (__NR_Linux + 36)
794#define __NR_alarm (__NR_Linux + 37)
795#define __NR_getpid (__NR_Linux + 38)
796#define __NR_sendfile (__NR_Linux + 39)
797#define __NR_socket (__NR_Linux + 40)
798#define __NR_connect (__NR_Linux + 41)
799#define __NR_accept (__NR_Linux + 42)
800#define __NR_sendto (__NR_Linux + 43)
801#define __NR_recvfrom (__NR_Linux + 44)
802#define __NR_sendmsg (__NR_Linux + 45)
803#define __NR_recvmsg (__NR_Linux + 46)
804#define __NR_shutdown (__NR_Linux + 47)
805#define __NR_bind (__NR_Linux + 48)
806#define __NR_listen (__NR_Linux + 49)
807#define __NR_getsockname (__NR_Linux + 50)
808#define __NR_getpeername (__NR_Linux + 51)
809#define __NR_socketpair (__NR_Linux + 52)
810#define __NR_setsockopt (__NR_Linux + 53)
811#define __NR_getsockopt (__NR_Linux + 54)
812#define __NR_clone (__NR_Linux + 55)
813#define __NR_fork (__NR_Linux + 56)
814#define __NR_execve (__NR_Linux + 57)
815#define __NR_exit (__NR_Linux + 58)
816#define __NR_wait4 (__NR_Linux + 59)
817#define __NR_kill (__NR_Linux + 60)
818#define __NR_uname (__NR_Linux + 61)
819#define __NR_semget (__NR_Linux + 62)
820#define __NR_semop (__NR_Linux + 63)
821#define __NR_semctl (__NR_Linux + 64)
822#define __NR_shmdt (__NR_Linux + 65)
823#define __NR_msgget (__NR_Linux + 66)
824#define __NR_msgsnd (__NR_Linux + 67)
825#define __NR_msgrcv (__NR_Linux + 68)
826#define __NR_msgctl (__NR_Linux + 69)
827#define __NR_fcntl (__NR_Linux + 70)
828#define __NR_flock (__NR_Linux + 71)
829#define __NR_fsync (__NR_Linux + 72)
830#define __NR_fdatasync (__NR_Linux + 73)
831#define __NR_truncate (__NR_Linux + 74)
832#define __NR_ftruncate (__NR_Linux + 75)
833#define __NR_getdents (__NR_Linux + 76)
834#define __NR_getcwd (__NR_Linux + 77)
835#define __NR_chdir (__NR_Linux + 78)
836#define __NR_fchdir (__NR_Linux + 79)
837#define __NR_rename (__NR_Linux + 80)
838#define __NR_mkdir (__NR_Linux + 81)
839#define __NR_rmdir (__NR_Linux + 82)
840#define __NR_creat (__NR_Linux + 83)
841#define __NR_link (__NR_Linux + 84)
842#define __NR_unlink (__NR_Linux + 85)
843#define __NR_symlink (__NR_Linux + 86)
844#define __NR_readlink (__NR_Linux + 87)
845#define __NR_chmod (__NR_Linux + 88)
846#define __NR_fchmod (__NR_Linux + 89)
847#define __NR_chown (__NR_Linux + 90)
848#define __NR_fchown (__NR_Linux + 91)
849#define __NR_lchown (__NR_Linux + 92)
850#define __NR_umask (__NR_Linux + 93)
851#define __NR_gettimeofday (__NR_Linux + 94)
852#define __NR_getrlimit (__NR_Linux + 95)
853#define __NR_getrusage (__NR_Linux + 96)
854#define __NR_sysinfo (__NR_Linux + 97)
855#define __NR_times (__NR_Linux + 98)
856#define __NR_ptrace (__NR_Linux + 99)
857#define __NR_getuid (__NR_Linux + 100)
858#define __NR_syslog (__NR_Linux + 101)
859#define __NR_getgid (__NR_Linux + 102)
860#define __NR_setuid (__NR_Linux + 103)
861#define __NR_setgid (__NR_Linux + 104)
862#define __NR_geteuid (__NR_Linux + 105)
863#define __NR_getegid (__NR_Linux + 106)
864#define __NR_setpgid (__NR_Linux + 107)
865#define __NR_getppid (__NR_Linux + 108)
866#define __NR_getpgrp (__NR_Linux + 109)
867#define __NR_setsid (__NR_Linux + 110)
868#define __NR_setreuid (__NR_Linux + 111)
869#define __NR_setregid (__NR_Linux + 112)
870#define __NR_getgroups (__NR_Linux + 113)
871#define __NR_setgroups (__NR_Linux + 114)
872#define __NR_setresuid (__NR_Linux + 115)
873#define __NR_getresuid (__NR_Linux + 116)
874#define __NR_setresgid (__NR_Linux + 117)
875#define __NR_getresgid (__NR_Linux + 118)
876#define __NR_getpgid (__NR_Linux + 119)
877#define __NR_setfsuid (__NR_Linux + 120)
878#define __NR_setfsgid (__NR_Linux + 121)
879#define __NR_getsid (__NR_Linux + 122)
880#define __NR_capget (__NR_Linux + 123)
881#define __NR_capset (__NR_Linux + 124)
882#define __NR_rt_sigpending (__NR_Linux + 125)
883#define __NR_rt_sigtimedwait (__NR_Linux + 126)
884#define __NR_rt_sigqueueinfo (__NR_Linux + 127)
885#define __NR_rt_sigsuspend (__NR_Linux + 128)
886#define __NR_sigaltstack (__NR_Linux + 129)
887#define __NR_utime (__NR_Linux + 130)
888#define __NR_mknod (__NR_Linux + 131)
889#define __NR_personality (__NR_Linux + 132)
890#define __NR_ustat (__NR_Linux + 133)
891#define __NR_statfs (__NR_Linux + 134)
892#define __NR_fstatfs (__NR_Linux + 135)
893#define __NR_sysfs (__NR_Linux + 136)
894#define __NR_getpriority (__NR_Linux + 137)
895#define __NR_setpriority (__NR_Linux + 138)
896#define __NR_sched_setparam (__NR_Linux + 139)
897#define __NR_sched_getparam (__NR_Linux + 140)
898#define __NR_sched_setscheduler (__NR_Linux + 141)
899#define __NR_sched_getscheduler (__NR_Linux + 142)
900#define __NR_sched_get_priority_max (__NR_Linux + 143)
901#define __NR_sched_get_priority_min (__NR_Linux + 144)
902#define __NR_sched_rr_get_interval (__NR_Linux + 145)
903#define __NR_mlock (__NR_Linux + 146)
904#define __NR_munlock (__NR_Linux + 147)
905#define __NR_mlockall (__NR_Linux + 148)
906#define __NR_munlockall (__NR_Linux + 149)
907#define __NR_vhangup (__NR_Linux + 150)
908#define __NR_pivot_root (__NR_Linux + 151)
909#define __NR__sysctl (__NR_Linux + 152)
910#define __NR_prctl (__NR_Linux + 153)
911#define __NR_adjtimex (__NR_Linux + 154)
912#define __NR_setrlimit (__NR_Linux + 155)
913#define __NR_chroot (__NR_Linux + 156)
914#define __NR_sync (__NR_Linux + 157)
915#define __NR_acct (__NR_Linux + 158)
916#define __NR_settimeofday (__NR_Linux + 159)
917#define __NR_mount (__NR_Linux + 160)
918#define __NR_umount2 (__NR_Linux + 161)
919#define __NR_swapon (__NR_Linux + 162)
920#define __NR_swapoff (__NR_Linux + 163)
921#define __NR_reboot (__NR_Linux + 164)
922#define __NR_sethostname (__NR_Linux + 165)
923#define __NR_setdomainname (__NR_Linux + 166)
924#define __NR_create_module (__NR_Linux + 167)
925#define __NR_init_module (__NR_Linux + 168)
926#define __NR_delete_module (__NR_Linux + 169)
927#define __NR_get_kernel_syms (__NR_Linux + 170)
928#define __NR_query_module (__NR_Linux + 171)
929#define __NR_quotactl (__NR_Linux + 172)
930#define __NR_nfsservctl (__NR_Linux + 173)
931#define __NR_getpmsg (__NR_Linux + 174)
932#define __NR_putpmsg (__NR_Linux + 175)
933#define __NR_afs_syscall (__NR_Linux + 176)
934#define __NR_reserved177 (__NR_Linux + 177)
935#define __NR_gettid (__NR_Linux + 178)
936#define __NR_readahead (__NR_Linux + 179)
937#define __NR_setxattr (__NR_Linux + 180)
938#define __NR_lsetxattr (__NR_Linux + 181)
939#define __NR_fsetxattr (__NR_Linux + 182)
940#define __NR_getxattr (__NR_Linux + 183)
941#define __NR_lgetxattr (__NR_Linux + 184)
942#define __NR_fgetxattr (__NR_Linux + 185)
943#define __NR_listxattr (__NR_Linux + 186)
944#define __NR_llistxattr (__NR_Linux + 187)
945#define __NR_flistxattr (__NR_Linux + 188)
946#define __NR_removexattr (__NR_Linux + 189)
947#define __NR_lremovexattr (__NR_Linux + 190)
948#define __NR_fremovexattr (__NR_Linux + 191)
949#define __NR_tkill (__NR_Linux + 192)
950#define __NR_reserved193 (__NR_Linux + 193)
951#define __NR_futex (__NR_Linux + 194)
952#define __NR_sched_setaffinity (__NR_Linux + 195)
953#define __NR_sched_getaffinity (__NR_Linux + 196)
954#define __NR_cacheflush (__NR_Linux + 197)
955#define __NR_cachectl (__NR_Linux + 198)
956#define __NR_sysmips (__NR_Linux + 199)
957#define __NR_io_setup (__NR_Linux + 200)
958#define __NR_io_destroy (__NR_Linux + 201)
959#define __NR_io_getevents (__NR_Linux + 202)
960#define __NR_io_submit (__NR_Linux + 203)
961#define __NR_io_cancel (__NR_Linux + 204)
962#define __NR_exit_group (__NR_Linux + 205)
963#define __NR_lookup_dcookie (__NR_Linux + 206)
964#define __NR_epoll_create (__NR_Linux + 207)
965#define __NR_epoll_ctl (__NR_Linux + 208)
966#define __NR_epoll_wait (__NR_Linux + 209)
967#define __NR_remap_file_pages (__NR_Linux + 210)
968#define __NR_rt_sigreturn (__NR_Linux + 211)
969#define __NR_fcntl64 (__NR_Linux + 212)
970#define __NR_set_tid_address (__NR_Linux + 213)
971#define __NR_restart_syscall (__NR_Linux + 214)
972#define __NR_semtimedop (__NR_Linux + 215)
973#define __NR_fadvise64 (__NR_Linux + 216)
974#define __NR_statfs64 (__NR_Linux + 217)
975#define __NR_fstatfs64 (__NR_Linux + 218)
976#define __NR_sendfile64 (__NR_Linux + 219)
977#define __NR_timer_create (__NR_Linux + 220)
978#define __NR_timer_settime (__NR_Linux + 221)
979#define __NR_timer_gettime (__NR_Linux + 222)
980#define __NR_timer_getoverrun (__NR_Linux + 223)
981#define __NR_timer_delete (__NR_Linux + 224)
982#define __NR_clock_settime (__NR_Linux + 225)
983#define __NR_clock_gettime (__NR_Linux + 226)
984#define __NR_clock_getres (__NR_Linux + 227)
985#define __NR_clock_nanosleep (__NR_Linux + 228)
986#define __NR_tgkill (__NR_Linux + 229)
987#define __NR_utimes (__NR_Linux + 230)
988#define __NR_mbind (__NR_Linux + 231)
989#define __NR_get_mempolicy (__NR_Linux + 232)
990#define __NR_set_mempolicy (__NR_Linux + 233)
991#define __NR_mq_open (__NR_Linux + 234)
992#define __NR_mq_unlink (__NR_Linux + 235)
993#define __NR_mq_timedsend (__NR_Linux + 236)
994#define __NR_mq_timedreceive (__NR_Linux + 237)
995#define __NR_mq_notify (__NR_Linux + 238)
996#define __NR_mq_getsetattr (__NR_Linux + 239)
997#define __NR_vserver (__NR_Linux + 240)
998#define __NR_waitid (__NR_Linux + 241)
999/* #define __NR_sys_setaltroot (__NR_Linux + 242) */
1000#define __NR_add_key (__NR_Linux + 243)
1001#define __NR_request_key (__NR_Linux + 244)
1002#define __NR_keyctl (__NR_Linux + 245)
1003#define __NR_set_thread_area (__NR_Linux + 246)
1004#define __NR_inotify_init (__NR_Linux + 247)
1005#define __NR_inotify_add_watch (__NR_Linux + 248)
1006#define __NR_inotify_rm_watch (__NR_Linux + 249)
1007#define __NR_migrate_pages (__NR_Linux + 250)
1008#define __NR_openat (__NR_Linux + 251)
1009#define __NR_mkdirat (__NR_Linux + 252)
1010#define __NR_mknodat (__NR_Linux + 253)
1011#define __NR_fchownat (__NR_Linux + 254)
1012#define __NR_futimesat (__NR_Linux + 255)
1013#define __NR_newfstatat (__NR_Linux + 256)
1014#define __NR_unlinkat (__NR_Linux + 257)
1015#define __NR_renameat (__NR_Linux + 258)
1016#define __NR_linkat (__NR_Linux + 259)
1017#define __NR_symlinkat (__NR_Linux + 260)
1018#define __NR_readlinkat (__NR_Linux + 261)
1019#define __NR_fchmodat (__NR_Linux + 262)
1020#define __NR_faccessat (__NR_Linux + 263)
1021#define __NR_pselect6 (__NR_Linux + 264)
1022#define __NR_ppoll (__NR_Linux + 265)
1023#define __NR_unshare (__NR_Linux + 266)
1024#define __NR_splice (__NR_Linux + 267)
1025#define __NR_sync_file_range (__NR_Linux + 268)
1026#define __NR_tee (__NR_Linux + 269)
1027#define __NR_vmsplice (__NR_Linux + 270)
1028#define __NR_move_pages (__NR_Linux + 271)
1029#define __NR_set_robust_list (__NR_Linux + 272)
1030#define __NR_get_robust_list (__NR_Linux + 273)
1031#define __NR_kexec_load (__NR_Linux + 274)
1032#define __NR_getcpu (__NR_Linux + 275)
1033#define __NR_epoll_pwait (__NR_Linux + 276)
1034#define __NR_ioprio_set (__NR_Linux + 277)
1035#define __NR_ioprio_get (__NR_Linux + 278)
1036#define __NR_utimensat (__NR_Linux + 279)
1037#define __NR_signalfd (__NR_Linux + 280)
1038#define __NR_timerfd (__NR_Linux + 281)
1039#define __NR_eventfd (__NR_Linux + 282)
1040#define __NR_fallocate (__NR_Linux + 283)
1041#define __NR_timerfd_create (__NR_Linux + 284)
1042#define __NR_timerfd_gettime (__NR_Linux + 285)
1043#define __NR_timerfd_settime (__NR_Linux + 286)
1044#define __NR_signalfd4 (__NR_Linux + 287)
1045#define __NR_eventfd2 (__NR_Linux + 288)
1046#define __NR_epoll_create1 (__NR_Linux + 289)
1047#define __NR_dup3 (__NR_Linux + 290)
1048#define __NR_pipe2 (__NR_Linux + 291)
1049#define __NR_inotify_init1 (__NR_Linux + 292)
1050#define __NR_preadv (__NR_Linux + 293)
1051#define __NR_pwritev (__NR_Linux + 294)
1052#define __NR_rt_tgsigqueueinfo (__NR_Linux + 295)
1053#define __NR_perf_event_open (__NR_Linux + 296)
1054#define __NR_accept4 (__NR_Linux + 297)
1055#define __NR_recvmmsg (__NR_Linux + 298)
1056#define __NR_getdents64 (__NR_Linux + 299)
1057#define __NR_fanotify_init (__NR_Linux + 300)
1058#define __NR_fanotify_mark (__NR_Linux + 301)
1059#define __NR_prlimit64 (__NR_Linux + 302)
1060#define __NR_name_to_handle_at (__NR_Linux + 303)
1061#define __NR_open_by_handle_at (__NR_Linux + 304)
1062#define __NR_clock_adjtime (__NR_Linux + 305)
1063#define __NR_syncfs (__NR_Linux + 306)
1064#define __NR_sendmmsg (__NR_Linux + 307)
1065#define __NR_setns (__NR_Linux + 308)
1066#define __NR_process_vm_readv (__NR_Linux + 309)
1067#define __NR_process_vm_writev (__NR_Linux + 310)
1068#define __NR_kcmp (__NR_Linux + 311)
1069#define __NR_finit_module (__NR_Linux + 312)
1070#define __NR_sched_setattr (__NR_Linux + 313)
1071#define __NR_sched_getattr (__NR_Linux + 314)
1072#define __NR_renameat2 (__NR_Linux + 315)
1073#define __NR_seccomp (__NR_Linux + 316)
1074#define __NR_getrandom (__NR_Linux + 317)
1075#define __NR_memfd_create (__NR_Linux + 318)
1076#define __NR_bpf (__NR_Linux + 319)
1077#define __NR_execveat (__NR_Linux + 320)
1078#define __NR_userfaultfd (__NR_Linux + 321)
1079#define __NR_membarrier (__NR_Linux + 322)
1080#define __NR_mlock2 (__NR_Linux + 323)
1081#define __NR_copy_file_range (__NR_Linux + 324)
1082#define __NR_preadv2 (__NR_Linux + 325)
1083#define __NR_pwritev2 (__NR_Linux + 326)
1084#define __NR_pkey_mprotect (__NR_Linux + 327)
1085#define __NR_pkey_alloc (__NR_Linux + 328)
1086#define __NR_pkey_free (__NR_Linux + 329)
1087#define __NR_statx (__NR_Linux + 330)
1088#define __NR_rseq (__NR_Linux + 331)
1089#define __NR_io_pgetevents (__NR_Linux + 332)
1090
1091/*
1092 * Offset of the last N32 flavoured syscall
1093 */
1094#define __NR_Linux_syscalls 332
1095
1096#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
1097
1098#define __NR_N32_Linux 6000
1099#define __NR_N32_Linux_syscalls 332
1100
1101#endif /* _UAPI_ASM_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/mips/bits/stat.h created+263
...@@ -0,0 +1,263 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <sgidefs.h>
26
27/* Versions of the `struct stat' data structure. */
28#define _STAT_VER_LINUX_OLD 1
29#define _STAT_VER_KERNEL 1
30#define _STAT_VER_SVR4 2
31#define _STAT_VER_LINUX 3
32#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
33
34/* Versions of the `xmknod' interface. */
35#define _MKNOD_VER_LINUX 1
36#define _MKNOD_VER_SVR4 2
37#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
38
39
40#if _MIPS_SIM == _ABIO32
41/* Structure describing file characteristics. */
42struct stat
43 {
44 unsigned long int st_dev;
45 long int st_pad1[3];
46#ifndef __USE_FILE_OFFSET64
47 __ino_t st_ino; /* File serial number. */
48#else
49 __ino64_t st_ino; /* File serial number. */
50#endif
51 __mode_t st_mode; /* File mode. */
52 __nlink_t st_nlink; /* Link count. */
53 __uid_t st_uid; /* User ID of the file's owner. */
54 __gid_t st_gid; /* Group ID of the file's group.*/
55 unsigned long int st_rdev; /* Device number, if device. */
56#ifndef __USE_FILE_OFFSET64
57 long int st_pad2[2];
58 __off_t st_size; /* Size of file, in bytes. */
59 /* SVR4 added this extra long to allow for expansion of off_t. */
60 long int st_pad3;
61#else
62 long int st_pad2[3];
63 __off64_t st_size; /* Size of file, in bytes. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86 __blksize_t st_blksize; /* Optimal block size for I/O. */
87#ifndef __USE_FILE_OFFSET64
88 __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
89#else
90 long int st_pad4;
91 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
92#endif
93 long int st_pad5[14];
94 };
95
96#ifdef __USE_LARGEFILE64
97struct stat64
98 {
99 unsigned long int st_dev;
100 long int st_pad1[3];
101 __ino64_t st_ino; /* File serial number. */
102 __mode_t st_mode; /* File mode. */
103 __nlink_t st_nlink; /* Link count. */
104 __uid_t st_uid; /* User ID of the file's owner. */
105 __gid_t st_gid; /* Group ID of the file's group.*/
106 unsigned long int st_rdev; /* Device number, if device. */
107 long int st_pad2[3];
108 __off64_t st_size; /* Size of file, in bytes. */
109# ifdef __USE_XOPEN2K8
110 /* Nanosecond resolution timestamps are stored in a format
111 equivalent to 'struct timespec'. This is the type used
112 whenever possible but the Unix namespace rules do not allow the
113 identifier 'timespec' to appear in the <sys/stat.h> header.
114 Therefore we have to handle the use of this header in strictly
115 standard-compliant sources special. */
116 struct timespec st_atim; /* Time of last access. */
117 struct timespec st_mtim; /* Time of last modification. */
118 struct timespec st_ctim; /* Time of last status change. */
119# else
120 __time_t st_atime; /* Time of last access. */
121 unsigned long int st_atimensec; /* Nscecs of last access. */
122 __time_t st_mtime; /* Time of last modification. */
123 unsigned long int st_mtimensec; /* Nsecs of last modification. */
124 __time_t st_ctime; /* Time of last status change. */
125 unsigned long int st_ctimensec; /* Nsecs of last status change. */
126# endif
127 __blksize_t st_blksize; /* Optimal block size for I/O. */
128 long int st_pad3;
129 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
130 long int st_pad4[14];
131 };
132#endif
133#else
134struct stat
135 {
136 __dev_t st_dev;
137 int st_pad1[3]; /* Reserved for st_dev expansion */
138#ifndef __USE_FILE_OFFSET64
139 __ino_t st_ino;
140#else
141 __ino64_t st_ino;
142#endif
143 __mode_t st_mode;
144 __nlink_t st_nlink;
145 __uid_t st_uid;
146 __gid_t st_gid;
147 __dev_t st_rdev;
148#if !defined __USE_FILE_OFFSET64
149 unsigned int st_pad2[2]; /* Reserved for st_rdev expansion */
150 __off_t st_size;
151 int st_pad3;
152#else
153 unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
154 __off64_t st_size;
155#endif
156#ifdef __USE_XOPEN2K8
157 /* Nanosecond resolution timestamps are stored in a format
158 equivalent to 'struct timespec'. This is the type used
159 whenever possible but the Unix namespace rules do not allow the
160 identifier 'timespec' to appear in the <sys/stat.h> header.
161 Therefore we have to handle the use of this header in strictly
162 standard-compliant sources special. */
163 struct timespec st_atim; /* Time of last access. */
164 struct timespec st_mtim; /* Time of last modification. */
165 struct timespec st_ctim; /* Time of last status change. */
166# define st_atime st_atim.tv_sec /* Backward compatibility. */
167# define st_mtime st_mtim.tv_sec
168# define st_ctime st_ctim.tv_sec
169#else
170 __time_t st_atime; /* Time of last access. */
171 unsigned long int st_atimensec; /* Nscecs of last access. */
172 __time_t st_mtime; /* Time of last modification. */
173 unsigned long int st_mtimensec; /* Nsecs of last modification. */
174 __time_t st_ctime; /* Time of last status change. */
175 unsigned long int st_ctimensec; /* Nsecs of last status change. */
176#endif
177 __blksize_t st_blksize;
178 unsigned int st_pad4;
179#ifndef __USE_FILE_OFFSET64
180 __blkcnt_t st_blocks;
181#else
182 __blkcnt64_t st_blocks;
183#endif
184 int st_pad5[14];
185 };
186
187#ifdef __USE_LARGEFILE64
188struct stat64
189 {
190 __dev_t st_dev;
191 unsigned int st_pad1[3]; /* Reserved for st_dev expansion */
192 __ino64_t st_ino;
193 __mode_t st_mode;
194 __nlink_t st_nlink;
195 __uid_t st_uid;
196 __gid_t st_gid;
197 __dev_t st_rdev;
198 unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
199 __off64_t st_size;
200# ifdef __USE_XOPEN2K8
201 /* Nanosecond resolution timestamps are stored in a format
202 equivalent to 'struct timespec'. This is the type used
203 whenever possible but the Unix namespace rules do not allow the
204 identifier 'timespec' to appear in the <sys/stat.h> header.
205 Therefore we have to handle the use of this header in strictly
206 standard-compliant sources special. */
207 struct timespec st_atim; /* Time of last access. */
208 struct timespec st_mtim; /* Time of last modification. */
209 struct timespec st_ctim; /* Time of last status change. */
210# else
211 __time_t st_atime; /* Time of last access. */
212 unsigned long int st_atimensec; /* Nscecs of last access. */
213 __time_t st_mtime; /* Time of last modification. */
214 unsigned long int st_mtimensec; /* Nsecs of last modification. */
215 __time_t st_ctime; /* Time of last status change. */
216 unsigned long int st_ctimensec; /* Nsecs of last status change. */
217# endif
218 __blksize_t st_blksize;
219 unsigned int st_pad3;
220 __blkcnt64_t st_blocks;
221 int st_pad4[14];
222};
223#endif
224#endif
225
226/* Tell code we have these members. */
227#define _STATBUF_ST_BLKSIZE
228#define _STATBUF_ST_RDEV
229
230/* Encoding of the file mode. */
231
232#define __S_IFMT 0170000 /* These bits determine file type. */
233
234/* File types. */
235#define __S_IFDIR 0040000 /* Directory. */
236#define __S_IFCHR 0020000 /* Character device. */
237#define __S_IFBLK 0060000 /* Block device. */
238#define __S_IFREG 0100000 /* Regular file. */
239#define __S_IFIFO 0010000 /* FIFO. */
240#define __S_IFLNK 0120000 /* Symbolic link. */
241#define __S_IFSOCK 0140000 /* Socket. */
242
243/* POSIX.1b objects. Note that these macros always evaluate to zero. But
244 they do it by enforcing the correct use of the macros. */
245#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
246#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
247#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
248
249/* Protection bits. */
250
251#define __S_ISUID 04000 /* Set user ID on execution. */
252#define __S_ISGID 02000 /* Set group ID on execution. */
253#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
254#define __S_IREAD 0400 /* Read by owner. */
255#define __S_IWRITE 0200 /* Write by owner. */
256#define __S_IEXEC 0100 /* Execute by owner. */
257
258#ifdef __USE_ATFILE
259# define UTIME_NOW ((1l << 30) - 1l)
260# define UTIME_OMIT ((1l << 30) - 2l)
261#endif
262
263#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/mips/kernel-features.h created+52
...@@ -0,0 +1,52 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <sgidefs.h>
21
22#include_next <kernel-features.h>
23
24/* The MIPS kernel does not support futex_atomic_cmpxchg_inatomic if
25 emulating LL/SC. */
26#if __mips == 1 || defined _MIPS_ARCH_R5900
27# undef __ASSUME_SET_ROBUST_LIST
28#endif
29
30/* Define this if your 32-bit syscall API requires 64-bit register
31 pairs to start with an even-number register. */
32#if _MIPS_SIM == _ABIO32
33# define __ASSUME_ALIGNED_REGISTER_PAIRS 1
34/* mips32 only supports ipc syscall. */
35# undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
36
37/* The o32 MIPS fadvise64 syscall behaves as fadvise64_64. */
38# define __ASSUME_FADVISE64_AS_64_64 1
39
40/* mips32 support wire-up network syscalls. */
41# define __ASSUME_RECV_SYSCALL 1
42# define __ASSUME_SEND_SYSCALL 1
43#endif
44
45/* Define that mips64-n32 is a ILP32 ABI to set the correct interface to
46 pass 64-bits values through syscalls. */
47#if _MIPS_SIM == _ABIN32
48# define __ASSUME_WORDSIZE64_ILP32 1
49#endif
50
51#undef __ASSUME_CLONE_DEFAULT
52#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h created+376
...@@ -0,0 +1,376 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_MIPS_MIPS32_SYSDEP_H
19#define _LINUX_MIPS_MIPS32_SYSDEP_H 1
20
21/* Always enable vsyscalls on mips32. */
22#define ALWAYS_USE_VSYSCALL 1
23
24/* There is some commonality. */
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <sysdeps/unix/mips/mips32/sysdep.h>
27
28#include <tls.h>
29
30/* In order to get __set_errno() definition in INLINE_SYSCALL. */
31#ifndef __ASSEMBLER__
32#include <errno.h>
33#endif
34
35/* For Linux we can use the system call table in the header file
36 /usr/include/asm/unistd.h
37 of the kernel. But these symbols do not follow the SYS_* syntax
38 so we have to redefine the `SYS_ify' macro here. */
39#undef SYS_ify
40#define SYS_ify(syscall_name) __NR_##syscall_name
41
42#ifdef __ASSEMBLER__
43
44/* We don't want the label for the error handler to be visible in the symbol
45 table when we define it here. */
46#ifdef __PIC__
47# define SYSCALL_ERROR_LABEL 99b
48#endif
49
50#else /* ! __ASSEMBLER__ */
51
52/* Define a macro which expands into the inline wrapper code for a system
53 call. */
54#undef INLINE_SYSCALL
55#define INLINE_SYSCALL(name, nr, args...) \
56 ({ INTERNAL_SYSCALL_DECL (_sc_err); \
57 long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args); \
58 if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) ) \
59 { \
60 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err)); \
61 result_var = -1L; \
62 } \
63 result_var; })
64
65#undef INTERNAL_SYSCALL_DECL
66#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
67
68#undef INTERNAL_SYSCALL_ERROR_P
69#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err))
70
71#undef INTERNAL_SYSCALL_ERRNO
72#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
73
74/* Note that the original Linux syscall restart convention required the
75 instruction immediately preceding SYSCALL to initialize $v0 with the
76 syscall number. Then if a restart triggered, $v0 would have been
77 clobbered by the syscall interrupted, and needed to be reinititalized.
78 The kernel would decrement the PC by 4 before switching back to the
79 user mode so that $v0 had been reloaded before SYSCALL was executed
80 again. This implied the place $v0 was loaded from must have been
81 preserved across a syscall, e.g. an immediate, static register, stack
82 slot, etc.
83
84 The convention was relaxed in Linux with a change applied to the kernel
85 GIT repository as commit 96187fb0bc30cd7919759d371d810e928048249d, that
86 first appeared in the 2.6.36 release. Since then the kernel has had
87 code that reloads $v0 upon syscall restart and resumes right at the
88 SYSCALL instruction, so no special arrangement is needed anymore.
89
90 For backwards compatibility with existing kernel binaries we support
91 the old convention by choosing the instruction preceding SYSCALL
92 carefully. This also means we have to force a 32-bit encoding of the
93 microMIPS MOVE instruction if one is used. */
94
95#ifdef __mips_micromips
96# define MOVE32 "move32"
97#else
98# define MOVE32 "move"
99#endif
100
101#undef INTERNAL_SYSCALL
102#undef INTERNAL_SYSCALL_NCS
103
104#define __nomips16 __attribute__ ((nomips16))
105
106union __mips_syscall_return
107 {
108 long long val;
109 struct
110 {
111 long v0;
112 long v1;
113 }
114 reg;
115 };
116
117#ifdef __mips16
118/* There's no MIPS16 syscall instruction, so we go through out-of-line
119 standard MIPS wrappers. These do use inline snippets below though,
120 through INTERNAL_SYSCALL_MIPS16. Spilling the syscall number to
121 memory gives the best code in that case, avoiding the need to save
122 and restore a static register. */
123
124# include <mips16-syscall.h>
125
126# define INTERNAL_SYSCALL(name, err, nr, args...) \
127 INTERNAL_SYSCALL_NCS (SYS_ify (name), err, nr, args)
128
129# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
130({ \
131 union __mips_syscall_return _sc_ret; \
132 _sc_ret.val = __mips16_syscall##nr (args, number); \
133 err = _sc_ret.reg.v1; \
134 _sc_ret.reg.v0; \
135})
136
137# define INTERNAL_SYSCALL_MIPS16(number, err, nr, args...) \
138 internal_syscall##nr ("lw\t%0, %2\n\t", \
139 "R" (number), \
140 number, err, args)
141
142#else /* !__mips16 */
143# define INTERNAL_SYSCALL(name, err, nr, args...) \
144 internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t", \
145 "IK" (SYS_ify (name)), \
146 SYS_ify (name), err, args)
147
148# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
149 internal_syscall##nr (MOVE32 "\t%0, %2\n\t", \
150 "r" (__s0), \
151 number, err, args)
152
153#endif /* !__mips16 */
154
155#define internal_syscall0(v0_init, input, number, err, dummy...) \
156({ \
157 long _sys_result; \
158 \
159 { \
160 register long __s0 asm ("$16") __attribute__ ((unused)) \
161 = (number); \
162 register long __v0 asm ("$2"); \
163 register long __a3 asm ("$7"); \
164 __asm__ volatile ( \
165 ".set\tnoreorder\n\t" \
166 v0_init \
167 "syscall\n\t" \
168 ".set reorder" \
169 : "=r" (__v0), "=r" (__a3) \
170 : input \
171 : __SYSCALL_CLOBBERS); \
172 err = __a3; \
173 _sys_result = __v0; \
174 } \
175 _sys_result; \
176})
177
178#define internal_syscall1(v0_init, input, number, err, arg1) \
179({ \
180 long _sys_result; \
181 \
182 { \
183 register long __s0 asm ("$16") __attribute__ ((unused)) \
184 = (number); \
185 register long __v0 asm ("$2"); \
186 register long __a0 asm ("$4") = (long) (arg1); \
187 register long __a3 asm ("$7"); \
188 __asm__ volatile ( \
189 ".set\tnoreorder\n\t" \
190 v0_init \
191 "syscall\n\t" \
192 ".set reorder" \
193 : "=r" (__v0), "=r" (__a3) \
194 : input, "r" (__a0) \
195 : __SYSCALL_CLOBBERS); \
196 err = __a3; \
197 _sys_result = __v0; \
198 } \
199 _sys_result; \
200})
201
202#define internal_syscall2(v0_init, input, number, err, arg1, arg2) \
203({ \
204 long _sys_result; \
205 \
206 { \
207 register long __s0 asm ("$16") __attribute__ ((unused)) \
208 = (number); \
209 register long __v0 asm ("$2"); \
210 register long __a0 asm ("$4") = (long) (arg1); \
211 register long __a1 asm ("$5") = (long) (arg2); \
212 register long __a3 asm ("$7"); \
213 __asm__ volatile ( \
214 ".set\tnoreorder\n\t" \
215 v0_init \
216 "syscall\n\t" \
217 ".set\treorder" \
218 : "=r" (__v0), "=r" (__a3) \
219 : input, "r" (__a0), "r" (__a1) \
220 : __SYSCALL_CLOBBERS); \
221 err = __a3; \
222 _sys_result = __v0; \
223 } \
224 _sys_result; \
225})
226
227#define internal_syscall3(v0_init, input, number, err, \
228 arg1, arg2, arg3) \
229({ \
230 long _sys_result; \
231 \
232 { \
233 register long __s0 asm ("$16") __attribute__ ((unused)) \
234 = (number); \
235 register long __v0 asm ("$2"); \
236 register long __a0 asm ("$4") = (long) (arg1); \
237 register long __a1 asm ("$5") = (long) (arg2); \
238 register long __a2 asm ("$6") = (long) (arg3); \
239 register long __a3 asm ("$7"); \
240 __asm__ volatile ( \
241 ".set\tnoreorder\n\t" \
242 v0_init \
243 "syscall\n\t" \
244 ".set\treorder" \
245 : "=r" (__v0), "=r" (__a3) \
246 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
247 : __SYSCALL_CLOBBERS); \
248 err = __a3; \
249 _sys_result = __v0; \
250 } \
251 _sys_result; \
252})
253
254#define internal_syscall4(v0_init, input, number, err, \
255 arg1, arg2, arg3, arg4) \
256({ \
257 long _sys_result; \
258 \
259 { \
260 register long __s0 asm ("$16") __attribute__ ((unused)) \
261 = (number); \
262 register long __v0 asm ("$2"); \
263 register long __a0 asm ("$4") = (long) (arg1); \
264 register long __a1 asm ("$5") = (long) (arg2); \
265 register long __a2 asm ("$6") = (long) (arg3); \
266 register long __a3 asm ("$7") = (long) (arg4); \
267 __asm__ volatile ( \
268 ".set\tnoreorder\n\t" \
269 v0_init \
270 "syscall\n\t" \
271 ".set\treorder" \
272 : "=r" (__v0), "+r" (__a3) \
273 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
274 : __SYSCALL_CLOBBERS); \
275 err = __a3; \
276 _sys_result = __v0; \
277 } \
278 _sys_result; \
279})
280
281/* Standalone MIPS wrappers used for 5, 6, and 7 argument syscalls,
282 which require stack arguments. We rely on the compiler arranging
283 wrapper's arguments according to the MIPS o32 function calling
284 convention, which is reused by syscalls, except for the syscall
285 number passed and the error flag returned (taken care of in the
286 wrapper called). This relieves us from relying on non-guaranteed
287 compiler specifics required for the stack arguments to be pushed,
288 which would be the case if these syscalls were inlined. */
289
290long long __nomips16 __mips_syscall5 (long arg1, long arg2, long arg3,
291 long arg4, long arg5,
292 long number);
293libc_hidden_proto (__mips_syscall5, nomips16)
294
295#define internal_syscall5(v0_init, input, number, err, \
296 arg1, arg2, arg3, arg4, arg5) \
297({ \
298 union __mips_syscall_return _sc_ret; \
299 _sc_ret.val = __mips_syscall5 ((long) (arg1), \
300 (long) (arg2), \
301 (long) (arg3), \
302 (long) (arg4), \
303 (long) (arg5), \
304 (long) (number)); \
305 err = _sc_ret.reg.v1; \
306 _sc_ret.reg.v0; \
307})
308
309long long __nomips16 __mips_syscall6 (long arg1, long arg2, long arg3,
310 long arg4, long arg5, long arg6,
311 long number);
312libc_hidden_proto (__mips_syscall6, nomips16)
313
314#define internal_syscall6(v0_init, input, number, err, \
315 arg1, arg2, arg3, arg4, arg5, arg6) \
316({ \
317 union __mips_syscall_return _sc_ret; \
318 _sc_ret.val = __mips_syscall6 ((long) (arg1), \
319 (long) (arg2), \
320 (long) (arg3), \
321 (long) (arg4), \
322 (long) (arg5), \
323 (long) (arg6), \
324 (long) (number)); \
325 err = _sc_ret.reg.v1; \
326 _sc_ret.reg.v0; \
327})
328
329long long __nomips16 __mips_syscall7 (long arg1, long arg2, long arg3,
330 long arg4, long arg5, long arg6,
331 long arg7,
332 long number);
333libc_hidden_proto (__mips_syscall7, nomips16)
334
335#define internal_syscall7(v0_init, input, number, err, \
336 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
337({ \
338 union __mips_syscall_return _sc_ret; \
339 _sc_ret.val = __mips_syscall7 ((long) (arg1), \
340 (long) (arg2), \
341 (long) (arg3), \
342 (long) (arg4), \
343 (long) (arg5), \
344 (long) (arg6), \
345 (long) (arg7), \
346 (long) (number)); \
347 err = _sc_ret.reg.v1; \
348 _sc_ret.reg.v0; \
349})
350
351#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
352 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
353
354/* Standard MIPS syscalls have an error flag, and return a positive errno
355 when the error flag is set. Emulate this behaviour for vsyscalls so that
356 the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly. */
357#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
358 ({ \
359 long _ret = funcptr (args); \
360 err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \
361 if (err) \
362 _ret = -_ret; \
363 _ret; \
364 })
365
366/* List of system calls which are supported as vsyscalls. */
367#define HAVE_CLOCK_GETTIME_VSYSCALL 1
368#define HAVE_GETTIMEOFDAY_VSYSCALL 1
369
370#endif /* __ASSEMBLER__ */
371
372/* Pointer mangling is not yet supported for MIPS. */
373#define PTR_MANGLE(var) (void) (var)
374#define PTR_DEMANGLE(var) (void) (var)
375
376#endif /* linux/mips/mips32/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h created+324
...@@ -0,0 +1,324 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_MIPS_SYSDEP_H
19#define _LINUX_MIPS_SYSDEP_H 1
20
21/* Always enable vsyscalls on n32. */
22#define ALWAYS_USE_VSYSCALL 1
23
24/* There is some commonality. */
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <sysdeps/unix/mips/mips64/n32/sysdep.h>
27
28#include <tls.h>
29
30/* In order to get __set_errno() definition in INLINE_SYSCALL. */
31#ifndef __ASSEMBLER__
32#include <errno.h>
33#endif
34
35/* For Linux we can use the system call table in the header file
36 /usr/include/asm/unistd.h
37 of the kernel. But these symbols do not follow the SYS_* syntax
38 so we have to redefine the `SYS_ify' macro here. */
39#undef SYS_ify
40#define SYS_ify(syscall_name) __NR_##syscall_name
41
42#ifdef __ASSEMBLER__
43
44/* We don't want the label for the error handler to be visible in the symbol
45 table when we define it here. */
46# define SYSCALL_ERROR_LABEL 99b
47
48#else /* ! __ASSEMBLER__ */
49
50/* Convert X to a long long, without losing any bits if it is one
51 already or warning if it is a 32-bit pointer. */
52#define ARGIFY(X) ((long long) (__typeof__ ((X) - (X))) (X))
53
54/* Define a macro which expands into the inline wrapper code for a system
55 call. */
56#undef INLINE_SYSCALL
57#define INLINE_SYSCALL(name, nr, args...) \
58 ({ INTERNAL_SYSCALL_DECL (_sc_err); \
59 long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args); \
60 if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) ) \
61 { \
62 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err)); \
63 result_var = -1L; \
64 } \
65 result_var; })
66
67#undef INTERNAL_SYSCALL_DECL
68#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
69
70#undef INTERNAL_SYSCALL_ERROR_P
71#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err))
72
73#undef INTERNAL_SYSCALL_ERRNO
74#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
75
76/* Note that the original Linux syscall restart convention required the
77 instruction immediately preceding SYSCALL to initialize $v0 with the
78 syscall number. Then if a restart triggered, $v0 would have been
79 clobbered by the syscall interrupted, and needed to be reinititalized.
80 The kernel would decrement the PC by 4 before switching back to the
81 user mode so that $v0 had been reloaded before SYSCALL was executed
82 again. This implied the place $v0 was loaded from must have been
83 preserved across a syscall, e.g. an immediate, static register, stack
84 slot, etc.
85
86 The convention was relaxed in Linux with a change applied to the kernel
87 GIT repository as commit 96187fb0bc30cd7919759d371d810e928048249d, that
88 first appeared in the 2.6.36 release. Since then the kernel has had
89 code that reloads $v0 upon syscall restart and resumes right at the
90 SYSCALL instruction, so no special arrangement is needed anymore.
91
92 For backwards compatibility with existing kernel binaries we support
93 the old convention by choosing the instruction preceding SYSCALL
94 carefully. This also means we have to force a 32-bit encoding of the
95 microMIPS MOVE instruction if one is used. */
96
97#ifdef __mips_micromips
98# define MOVE32 "move32"
99#else
100# define MOVE32 "move"
101#endif
102
103#undef INTERNAL_SYSCALL
104#define INTERNAL_SYSCALL(name, err, nr, args...) \
105 internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t", \
106 "IK" (SYS_ify (name)), \
107 0, err, args)
108
109#undef INTERNAL_SYSCALL_NCS
110#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
111 internal_syscall##nr (MOVE32 "\t%0, %2\n\t", \
112 "r" (__s0), \
113 number, err, args)
114
115#define internal_syscall0(v0_init, input, number, err, dummy...) \
116({ \
117 long _sys_result; \
118 \
119 { \
120 register long long __s0 asm ("$16") __attribute__ ((unused)) \
121 = (number); \
122 register long long __v0 asm ("$2"); \
123 register long long __a3 asm ("$7"); \
124 __asm__ volatile ( \
125 ".set\tnoreorder\n\t" \
126 v0_init \
127 "syscall\n\t" \
128 ".set reorder" \
129 : "=r" (__v0), "=r" (__a3) \
130 : input \
131 : __SYSCALL_CLOBBERS); \
132 err = __a3; \
133 _sys_result = __v0; \
134 } \
135 _sys_result; \
136})
137
138#define internal_syscall1(v0_init, input, number, err, arg1) \
139({ \
140 long _sys_result; \
141 \
142 { \
143 register long long __s0 asm ("$16") __attribute__ ((unused)) \
144 = (number); \
145 register long long __v0 asm ("$2"); \
146 register long long __a0 asm ("$4") = ARGIFY (arg1); \
147 register long long __a3 asm ("$7"); \
148 __asm__ volatile ( \
149 ".set\tnoreorder\n\t" \
150 v0_init \
151 "syscall\n\t" \
152 ".set reorder" \
153 : "=r" (__v0), "=r" (__a3) \
154 : input, "r" (__a0) \
155 : __SYSCALL_CLOBBERS); \
156 err = __a3; \
157 _sys_result = __v0; \
158 } \
159 _sys_result; \
160})
161
162#define internal_syscall2(v0_init, input, number, err, arg1, arg2) \
163({ \
164 long _sys_result; \
165 \
166 { \
167 register long long __s0 asm ("$16") __attribute__ ((unused)) \
168 = (number); \
169 register long long __v0 asm ("$2"); \
170 register long long __a0 asm ("$4") = ARGIFY (arg1); \
171 register long long __a1 asm ("$5") = ARGIFY (arg2); \
172 register long long __a3 asm ("$7"); \
173 __asm__ volatile ( \
174 ".set\tnoreorder\n\t" \
175 v0_init \
176 "syscall\n\t" \
177 ".set\treorder" \
178 : "=r" (__v0), "=r" (__a3) \
179 : input, "r" (__a0), "r" (__a1) \
180 : __SYSCALL_CLOBBERS); \
181 err = __a3; \
182 _sys_result = __v0; \
183 } \
184 _sys_result; \
185})
186
187#define internal_syscall3(v0_init, input, number, err, \
188 arg1, arg2, arg3) \
189({ \
190 long _sys_result; \
191 \
192 { \
193 register long long __s0 asm ("$16") __attribute__ ((unused)) \
194 = (number); \
195 register long long __v0 asm ("$2"); \
196 register long long __a0 asm ("$4") = ARGIFY (arg1); \
197 register long long __a1 asm ("$5") = ARGIFY (arg2); \
198 register long long __a2 asm ("$6") = ARGIFY (arg3); \
199 register long long __a3 asm ("$7"); \
200 __asm__ volatile ( \
201 ".set\tnoreorder\n\t" \
202 v0_init \
203 "syscall\n\t" \
204 ".set\treorder" \
205 : "=r" (__v0), "=r" (__a3) \
206 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
207 : __SYSCALL_CLOBBERS); \
208 err = __a3; \
209 _sys_result = __v0; \
210 } \
211 _sys_result; \
212})
213
214#define internal_syscall4(v0_init, input, number, err, \
215 arg1, arg2, arg3, arg4) \
216({ \
217 long _sys_result; \
218 \
219 { \
220 register long long __s0 asm ("$16") __attribute__ ((unused)) \
221 = (number); \
222 register long long __v0 asm ("$2"); \
223 register long long __a0 asm ("$4") = ARGIFY (arg1); \
224 register long long __a1 asm ("$5") = ARGIFY (arg2); \
225 register long long __a2 asm ("$6") = ARGIFY (arg3); \
226 register long long __a3 asm ("$7") = ARGIFY (arg4); \
227 __asm__ volatile ( \
228 ".set\tnoreorder\n\t" \
229 v0_init \
230 "syscall\n\t" \
231 ".set\treorder" \
232 : "=r" (__v0), "+r" (__a3) \
233 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
234 : __SYSCALL_CLOBBERS); \
235 err = __a3; \
236 _sys_result = __v0; \
237 } \
238 _sys_result; \
239})
240
241#define internal_syscall5(v0_init, input, number, err, \
242 arg1, arg2, arg3, arg4, arg5) \
243({ \
244 long _sys_result; \
245 \
246 { \
247 register long long __s0 asm ("$16") __attribute__ ((unused)) \
248 = (number); \
249 register long long __v0 asm ("$2"); \
250 register long long __a0 asm ("$4") = ARGIFY (arg1); \
251 register long long __a1 asm ("$5") = ARGIFY (arg2); \
252 register long long __a2 asm ("$6") = ARGIFY (arg3); \
253 register long long __a3 asm ("$7") = ARGIFY (arg4); \
254 register long long __a4 asm ("$8") = ARGIFY (arg5); \
255 __asm__ volatile ( \
256 ".set\tnoreorder\n\t" \
257 v0_init \
258 "syscall\n\t" \
259 ".set\treorder" \
260 : "=r" (__v0), "+r" (__a3) \
261 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
262 : __SYSCALL_CLOBBERS); \
263 err = __a3; \
264 _sys_result = __v0; \
265 } \
266 _sys_result; \
267})
268
269#define internal_syscall6(v0_init, input, number, err, \
270 arg1, arg2, arg3, arg4, arg5, arg6) \
271({ \
272 long _sys_result; \
273 \
274 { \
275 register long long __s0 asm ("$16") __attribute__ ((unused)) \
276 = (number); \
277 register long long __v0 asm ("$2"); \
278 register long long __a0 asm ("$4") = ARGIFY (arg1); \
279 register long long __a1 asm ("$5") = ARGIFY (arg2); \
280 register long long __a2 asm ("$6") = ARGIFY (arg3); \
281 register long long __a3 asm ("$7") = ARGIFY (arg4); \
282 register long long __a4 asm ("$8") = ARGIFY (arg5); \
283 register long long __a5 asm ("$9") = ARGIFY (arg6); \
284 __asm__ volatile ( \
285 ".set\tnoreorder\n\t" \
286 v0_init \
287 "syscall\n\t" \
288 ".set\treorder" \
289 : "=r" (__v0), "+r" (__a3) \
290 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
291 "r" (__a5) \
292 : __SYSCALL_CLOBBERS); \
293 err = __a3; \
294 _sys_result = __v0; \
295 } \
296 _sys_result; \
297})
298
299#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
300 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
301
302/* Standard MIPS syscalls have an error flag, and return a positive errno
303 when the error flag is set. Emulate this behaviour for vsyscalls so that
304 the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly. */
305#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
306 ({ \
307 long _ret = funcptr (args); \
308 err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \
309 if (err) \
310 _ret = -_ret; \
311 _ret; \
312 })
313
314/* List of system calls which are supported as vsyscalls. */
315#define HAVE_CLOCK_GETTIME_VSYSCALL 1
316#define HAVE_GETTIMEOFDAY_VSYSCALL 1
317
318#endif /* __ASSEMBLER__ */
319
320/* Pointer mangling is not yet supported for MIPS. */
321#define PTR_MANGLE(var) (void) (var)
322#define PTR_DEMANGLE(var) (void) (var)
323
324#endif /* linux/mips/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h created+320
...@@ -0,0 +1,320 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_MIPS_SYSDEP_H
19#define _LINUX_MIPS_SYSDEP_H 1
20
21/* Always enable vsyscalls on n64. */
22#define ALWAYS_USE_VSYSCALL 1
23
24/* There is some commonality. */
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <sysdeps/unix/mips/mips64/n64/sysdep.h>
27
28#include <tls.h>
29
30/* In order to get __set_errno() definition in INLINE_SYSCALL. */
31#ifndef __ASSEMBLER__
32#include <errno.h>
33#endif
34
35/* For Linux we can use the system call table in the header file
36 /usr/include/asm/unistd.h
37 of the kernel. But these symbols do not follow the SYS_* syntax
38 so we have to redefine the `SYS_ify' macro here. */
39#undef SYS_ify
40#define SYS_ify(syscall_name) __NR_##syscall_name
41
42#ifdef __ASSEMBLER__
43
44/* We don't want the label for the error handler to be visible in the symbol
45 table when we define it here. */
46# define SYSCALL_ERROR_LABEL 99b
47
48#else /* ! __ASSEMBLER__ */
49
50/* Define a macro which expands into the inline wrapper code for a system
51 call. */
52#undef INLINE_SYSCALL
53#define INLINE_SYSCALL(name, nr, args...) \
54 ({ INTERNAL_SYSCALL_DECL (_sc_err); \
55 long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args); \
56 if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) ) \
57 { \
58 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err)); \
59 result_var = -1L; \
60 } \
61 result_var; })
62
63#undef INTERNAL_SYSCALL_DECL
64#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
65
66#undef INTERNAL_SYSCALL_ERROR_P
67#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err))
68
69#undef INTERNAL_SYSCALL_ERRNO
70#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
71
72/* Note that the original Linux syscall restart convention required the
73 instruction immediately preceding SYSCALL to initialize $v0 with the
74 syscall number. Then if a restart triggered, $v0 would have been
75 clobbered by the syscall interrupted, and needed to be reinititalized.
76 The kernel would decrement the PC by 4 before switching back to the
77 user mode so that $v0 had been reloaded before SYSCALL was executed
78 again. This implied the place $v0 was loaded from must have been
79 preserved across a syscall, e.g. an immediate, static register, stack
80 slot, etc.
81
82 The convention was relaxed in Linux with a change applied to the kernel
83 GIT repository as commit 96187fb0bc30cd7919759d371d810e928048249d, that
84 first appeared in the 2.6.36 release. Since then the kernel has had
85 code that reloads $v0 upon syscall restart and resumes right at the
86 SYSCALL instruction, so no special arrangement is needed anymore.
87
88 For backwards compatibility with existing kernel binaries we support
89 the old convention by choosing the instruction preceding SYSCALL
90 carefully. This also means we have to force a 32-bit encoding of the
91 microMIPS MOVE instruction if one is used. */
92
93#ifdef __mips_micromips
94# define MOVE32 "move32"
95#else
96# define MOVE32 "move"
97#endif
98
99#undef INTERNAL_SYSCALL
100#define INTERNAL_SYSCALL(name, err, nr, args...) \
101 internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t", \
102 "IK" (SYS_ify (name)), \
103 0, err, args)
104
105#undef INTERNAL_SYSCALL_NCS
106#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
107 internal_syscall##nr (MOVE32 "\t%0, %2\n\t", \
108 "r" (__s0), \
109 number, err, args)
110
111#define internal_syscall0(v0_init, input, number, err, dummy...) \
112({ \
113 long _sys_result; \
114 \
115 { \
116 register long __s0 asm ("$16") __attribute__ ((unused)) \
117 = (number); \
118 register long __v0 asm ("$2"); \
119 register long __a3 asm ("$7"); \
120 __asm__ volatile ( \
121 ".set\tnoreorder\n\t" \
122 v0_init \
123 "syscall\n\t" \
124 ".set reorder" \
125 : "=r" (__v0), "=r" (__a3) \
126 : input \
127 : __SYSCALL_CLOBBERS); \
128 err = __a3; \
129 _sys_result = __v0; \
130 } \
131 _sys_result; \
132})
133
134#define internal_syscall1(v0_init, input, number, err, arg1) \
135({ \
136 long _sys_result; \
137 \
138 { \
139 register long __s0 asm ("$16") __attribute__ ((unused)) \
140 = (number); \
141 register long __v0 asm ("$2"); \
142 register long __a0 asm ("$4") = (long) (arg1); \
143 register long __a3 asm ("$7"); \
144 __asm__ volatile ( \
145 ".set\tnoreorder\n\t" \
146 v0_init \
147 "syscall\n\t" \
148 ".set reorder" \
149 : "=r" (__v0), "=r" (__a3) \
150 : input, "r" (__a0) \
151 : __SYSCALL_CLOBBERS); \
152 err = __a3; \
153 _sys_result = __v0; \
154 } \
155 _sys_result; \
156})
157
158#define internal_syscall2(v0_init, input, number, err, arg1, arg2) \
159({ \
160 long _sys_result; \
161 \
162 { \
163 register long __s0 asm ("$16") __attribute__ ((unused)) \
164 = (number); \
165 register long __v0 asm ("$2"); \
166 register long __a0 asm ("$4") = (long) (arg1); \
167 register long __a1 asm ("$5") = (long) (arg2); \
168 register long __a3 asm ("$7"); \
169 __asm__ volatile ( \
170 ".set\tnoreorder\n\t" \
171 v0_init \
172 "syscall\n\t" \
173 ".set\treorder" \
174 : "=r" (__v0), "=r" (__a3) \
175 : input, "r" (__a0), "r" (__a1) \
176 : __SYSCALL_CLOBBERS); \
177 err = __a3; \
178 _sys_result = __v0; \
179 } \
180 _sys_result; \
181})
182
183#define internal_syscall3(v0_init, input, number, err, \
184 arg1, arg2, arg3) \
185({ \
186 long _sys_result; \
187 \
188 { \
189 register long __s0 asm ("$16") __attribute__ ((unused)) \
190 = (number); \
191 register long __v0 asm ("$2"); \
192 register long __a0 asm ("$4") = (long) (arg1); \
193 register long __a1 asm ("$5") = (long) (arg2); \
194 register long __a2 asm ("$6") = (long) (arg3); \
195 register long __a3 asm ("$7"); \
196 __asm__ volatile ( \
197 ".set\tnoreorder\n\t" \
198 v0_init \
199 "syscall\n\t" \
200 ".set\treorder" \
201 : "=r" (__v0), "=r" (__a3) \
202 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
203 : __SYSCALL_CLOBBERS); \
204 err = __a3; \
205 _sys_result = __v0; \
206 } \
207 _sys_result; \
208})
209
210#define internal_syscall4(v0_init, input, number, err, \
211 arg1, arg2, arg3, arg4) \
212({ \
213 long _sys_result; \
214 \
215 { \
216 register long __s0 asm ("$16") __attribute__ ((unused)) \
217 = (number); \
218 register long __v0 asm ("$2"); \
219 register long __a0 asm ("$4") = (long) (arg1); \
220 register long __a1 asm ("$5") = (long) (arg2); \
221 register long __a2 asm ("$6") = (long) (arg3); \
222 register long __a3 asm ("$7") = (long) (arg4); \
223 __asm__ volatile ( \
224 ".set\tnoreorder\n\t" \
225 v0_init \
226 "syscall\n\t" \
227 ".set\treorder" \
228 : "=r" (__v0), "+r" (__a3) \
229 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
230 : __SYSCALL_CLOBBERS); \
231 err = __a3; \
232 _sys_result = __v0; \
233 } \
234 _sys_result; \
235})
236
237#define internal_syscall5(v0_init, input, number, err, \
238 arg1, arg2, arg3, arg4, arg5) \
239({ \
240 long _sys_result; \
241 \
242 { \
243 register long __s0 asm ("$16") __attribute__ ((unused)) \
244 = (number); \
245 register long __v0 asm ("$2"); \
246 register long __a0 asm ("$4") = (long) (arg1); \
247 register long __a1 asm ("$5") = (long) (arg2); \
248 register long __a2 asm ("$6") = (long) (arg3); \
249 register long __a3 asm ("$7") = (long) (arg4); \
250 register long __a4 asm ("$8") = (long) (arg5); \
251 __asm__ volatile ( \
252 ".set\tnoreorder\n\t" \
253 v0_init \
254 "syscall\n\t" \
255 ".set\treorder" \
256 : "=r" (__v0), "+r" (__a3) \
257 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
258 : __SYSCALL_CLOBBERS); \
259 err = __a3; \
260 _sys_result = __v0; \
261 } \
262 _sys_result; \
263})
264
265#define internal_syscall6(v0_init, input, number, err, \
266 arg1, arg2, arg3, arg4, arg5, arg6) \
267({ \
268 long _sys_result; \
269 \
270 { \
271 register long __s0 asm ("$16") __attribute__ ((unused)) \
272 = (number); \
273 register long __v0 asm ("$2"); \
274 register long __a0 asm ("$4") = (long) (arg1); \
275 register long __a1 asm ("$5") = (long) (arg2); \
276 register long __a2 asm ("$6") = (long) (arg3); \
277 register long __a3 asm ("$7") = (long) (arg4); \
278 register long __a4 asm ("$8") = (long) (arg5); \
279 register long __a5 asm ("$9") = (long) (arg6); \
280 __asm__ volatile ( \
281 ".set\tnoreorder\n\t" \
282 v0_init \
283 "syscall\n\t" \
284 ".set\treorder" \
285 : "=r" (__v0), "+r" (__a3) \
286 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
287 "r" (__a5) \
288 : __SYSCALL_CLOBBERS); \
289 err = __a3; \
290 _sys_result = __v0; \
291 } \
292 _sys_result; \
293})
294
295#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
296 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
297
298/* Standard MIPS syscalls have an error flag, and return a positive errno
299 when the error flag is set. Emulate this behaviour for vsyscalls so that
300 the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly. */
301#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
302 ({ \
303 long _ret = funcptr (args); \
304 err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \
305 if (err) \
306 _ret = -_ret; \
307 _ret; \
308 })
309
310/* List of system calls which are supported as vsyscalls. */
311#define HAVE_CLOCK_GETTIME_VSYSCALL 1
312#define HAVE_GETTIMEOFDAY_VSYSCALL 1
313
314#endif /* __ASSEMBLER__ */
315
316/* Pointer mangling is not yet supported for MIPS. */
317#define PTR_MANGLE(var) (void) (var)
318#define PTR_DEMANGLE(var) (void) (var)
319
320#endif /* linux/mips/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/nios2/asm/unistd.h created+29
...@@ -0,0 +1,29 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * Copyright (C) 2013 Altera Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19 #define sys_mmap2 sys_mmap_pgoff
20
21#define __ARCH_WANT_RENAMEAT
22#define __ARCH_WANT_STAT64
23
24/* Use the standard ABI for syscalls */
25#include <asm-generic/unistd.h>
26
27/* Additional Nios II specific syscalls. */
28#define __NR_cacheflush (__NR_arch_specific_syscall)
29__SYSCALL(__NR_cacheflush, sys_cacheflush)
libc/glibc/sysdeps/unix/sysv/linux/nios2/sysdep.h created+264
...@@ -0,0 +1,264 @@
1/* Assembler macros for Nios II.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_NIOS2_SYSDEP_H
20#define _LINUX_NIOS2_SYSDEP_H 1
21
22#include <asm/unistd.h>
23#include <sysdeps/unix/sysdep.h>
24#include <sysdeps/nios2/sysdep.h>
25#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
26
27/* For RTLD_PRIVATE_ERRNO. */
28#include <dl-sysdep.h>
29
30#include <tls.h>
31
32/* For Linux we can use the system call table in the header file
33 /usr/include/asm/unistd.h
34 of the kernel. But these symbols do not follow the SYS_* syntax
35 so we have to redefine the `SYS_ify' macro here. */
36#undef SYS_ify
37#define SYS_ify(syscall_name) __NR_##syscall_name
38
39#ifdef __ASSEMBLER__
40
41#define SYSCALL_ERROR_LABEL __local_syscall_error
42
43#undef PSEUDO
44#define PSEUDO(name, syscall_name, args) \
45 ENTRY (name) \
46 DO_CALL (syscall_name, args) \
47 bne r7, zero, SYSCALL_ERROR_LABEL; \
48
49#undef PSEUDO_END
50#define PSEUDO_END(name) \
51 SYSCALL_ERROR_HANDLER \
52 END (name)
53
54#undef PSEUDO_NOERRNO
55#define PSEUDO_NOERRNO(name, syscall_name, args) \
56 ENTRY (name) \
57 DO_CALL (syscall_name, args)
58
59#undef PSEUDO_END_NOERRNO
60#define PSEUDO_END_NOERRNO(name) \
61 END (name)
62
63#undef ret_NOERRNO
64#define ret_NOERRNO ret
65
66#undef DO_CALL
67#define DO_CALL(syscall_name, args) \
68 DOARGS_##args \
69 movi r2, SYS_ify(syscall_name); \
70 trap;
71
72#if defined(__PIC__) || defined(PIC)
73
74# if RTLD_PRIVATE_ERRNO
75
76# define SYSCALL_ERROR_HANDLER \
77 SYSCALL_ERROR_LABEL: \
78 nextpc r3; \
791: \
80 movhi r8, %hiadj(rtld_errno - 1b); \
81 addi r8, r8, %lo(rtld_errno - 1b); \
82 add r3, r3, r8; \
83 stw r2, 0(r3); \
84 movi r2, -1; \
85 ret;
86
87# else
88
89# if IS_IN (libc)
90# define SYSCALL_ERROR_ERRNO __libc_errno
91# else
92# define SYSCALL_ERROR_ERRNO errno
93# endif
94# define SYSCALL_ERROR_HANDLER \
95 SYSCALL_ERROR_LABEL: \
96 nextpc r3; \
971: \
98 movhi r8, %hiadj(_gp_got - 1b); \
99 addi r8, r8, %lo(_gp_got - 1b); \
100 add r3, r3, r8; \
101 ldw r3, %tls_ie(SYSCALL_ERROR_ERRNO)(r3); \
102 add r3, r23, r3; \
103 stw r2, 0(r3); \
104 movi r2, -1; \
105 ret;
106
107# endif
108
109#else
110
111/* We can use a single error handler in the static library. */
112#define SYSCALL_ERROR_HANDLER \
113 SYSCALL_ERROR_LABEL: \
114 jmpi __syscall_error;
115
116#endif
117
118#define DOARGS_0 /* nothing */
119#define DOARGS_1 /* nothing */
120#define DOARGS_2 /* nothing */
121#define DOARGS_3 /* nothing */
122#define DOARGS_4 /* nothing */
123#define DOARGS_5 ldw r8, 0(sp);
124#define DOARGS_6 ldw r9, 4(sp); ldw r8, 0(sp);
125
126/* The function has to return the error code. */
127#undef PSEUDO_ERRVAL
128#define PSEUDO_ERRVAL(name, syscall_name, args) \
129 ENTRY (name) \
130 DO_CALL (syscall_name, args)
131
132#undef PSEUDO_END_ERRVAL
133#define PSEUDO_END_ERRVAL(name) \
134 END (name)
135
136#define ret_ERRVAL ret
137
138#else /* __ASSEMBLER__ */
139
140/* In order to get __set_errno() definition in INLINE_SYSCALL. */
141#include <errno.h>
142
143/* Previously Nios2 used the generic version without the libc_hidden_def
144 which lead in a non existent __send symbol in libc.so. */
145# undef HAVE_INTERNAL_SEND_SYMBOL
146
147/* Define a macro which expands into the inline wrapper code for a system
148 call. */
149#undef INLINE_SYSCALL
150#define INLINE_SYSCALL(name, nr, args...) \
151 ({ INTERNAL_SYSCALL_DECL(err); \
152 unsigned int result_var = INTERNAL_SYSCALL (name, err, nr, args); \
153 if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
154 { \
155 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
156 result_var = -1L; \
157 } \
158 (int) result_var; })
159
160#undef INTERNAL_SYSCALL_DECL
161#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
162
163#undef INTERNAL_SYSCALL_ERROR_P
164#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
165
166#undef INTERNAL_SYSCALL_ERRNO
167#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
168
169#undef INTERNAL_SYSCALL_RAW
170#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
171 ({ unsigned int _sys_result; \
172 { \
173 /* Load argument values in temporary variables
174 to perform side effects like function calls
175 before the call-used registers are set. */ \
176 LOAD_ARGS_##nr (args) \
177 LOAD_REGS_##nr \
178 register int _r2 asm ("r2") = (int)(name); \
179 register int _err asm ("r7"); \
180 asm volatile ("trap" \
181 : "+r" (_r2), "=r" (_err) \
182 : ASM_ARGS_##nr \
183 : __SYSCALL_CLOBBERS); \
184 _sys_result = _r2; \
185 err = _err; \
186 } \
187 (int) _sys_result; })
188
189#undef INTERNAL_SYSCALL
190#define INTERNAL_SYSCALL(name, err, nr, args...) \
191 INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
192
193#undef INTERNAL_SYSCALL_NCS
194#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
195 INTERNAL_SYSCALL_RAW(number, err, nr, args)
196
197#define LOAD_ARGS_0()
198#define LOAD_REGS_0
199#define ASM_ARGS_0
200#define LOAD_ARGS_1(a1) \
201 LOAD_ARGS_0 () \
202 int __arg1 = (int) (a1);
203#define LOAD_REGS_1 \
204 register int _r4 asm ("r4") = __arg1; \
205 LOAD_REGS_0
206#define ASM_ARGS_1 "r" (_r4)
207#define LOAD_ARGS_2(a1, a2) \
208 LOAD_ARGS_1 (a1) \
209 int __arg2 = (int) (a2);
210#define LOAD_REGS_2 \
211 register int _r5 asm ("r5") = __arg2; \
212 LOAD_REGS_1
213#define ASM_ARGS_2 ASM_ARGS_1, "r" (_r5)
214#define LOAD_ARGS_3(a1, a2, a3) \
215 LOAD_ARGS_2 (a1, a2) \
216 int __arg3 = (int) (a3);
217#define LOAD_REGS_3 \
218 register int _r6 asm ("r6") = __arg3; \
219 LOAD_REGS_2
220#define ASM_ARGS_3 ASM_ARGS_2, "r" (_r6)
221#define LOAD_ARGS_4(a1, a2, a3, a4) \
222 LOAD_ARGS_3 (a1, a2, a3) \
223 int __arg4 = (int) (a4);
224#define LOAD_REGS_4 \
225 register int _r7 asm ("r7") = __arg4; \
226 LOAD_REGS_3
227#define ASM_ARGS_4 ASM_ARGS_3, "r" (_r7)
228#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
229 LOAD_ARGS_4 (a1, a2, a3, a4) \
230 int __arg5 = (int) (a5);
231#define LOAD_REGS_5 \
232 register int _r8 asm ("r8") = __arg5; \
233 LOAD_REGS_4
234#define ASM_ARGS_5 ASM_ARGS_4, "r" (_r8)
235#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
236 LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
237 int __arg6 = (int) (a6);
238#define LOAD_REGS_6 \
239 register int _r9 asm ("r9") = __arg6; \
240 LOAD_REGS_5
241#define ASM_ARGS_6 ASM_ARGS_5, "r" (_r9)
242
243#define __SYSCALL_CLOBBERS "memory"
244
245#endif /* __ASSEMBLER__ */
246
247/* Pointer mangling support. */
248#if IS_IN (rtld)
249/* We cannot use the thread descriptor because in ld.so we use setjmp
250 earlier than the descriptor is initialized. */
251#else
252# ifdef __ASSEMBLER__
253# define PTR_MANGLE_GUARD(guard) ldw guard, POINTER_GUARD(r23)
254# define PTR_MANGLE(dst, src, guard) xor dst, src, guard
255# define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
256# else
257# define PTR_MANGLE(var) \
258 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
259# define PTR_DEMANGLE(var) PTR_MANGLE (var)
260# endif
261#endif
262
263
264#endif /* linux/nios2/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/powerpc/asm/unistd.h created+404
...@@ -0,0 +1,404 @@
1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2/*
3 * This file contains the system call numbers.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10#ifndef _UAPI_ASM_POWERPC_UNISTD_H_
11#define _UAPI_ASM_POWERPC_UNISTD_H_
12
13
14#define __NR_restart_syscall 0
15#define __NR_exit 1
16#define __NR_fork 2
17#define __NR_read 3
18#define __NR_write 4
19#define __NR_open 5
20#define __NR_close 6
21#define __NR_waitpid 7
22#define __NR_creat 8
23#define __NR_link 9
24#define __NR_unlink 10
25#define __NR_execve 11
26#define __NR_chdir 12
27#define __NR_time 13
28#define __NR_mknod 14
29#define __NR_chmod 15
30#define __NR_lchown 16
31#define __NR_break 17
32#define __NR_oldstat 18
33#define __NR_lseek 19
34#define __NR_getpid 20
35#define __NR_mount 21
36#define __NR_umount 22
37#define __NR_setuid 23
38#define __NR_getuid 24
39#define __NR_stime 25
40#define __NR_ptrace 26
41#define __NR_alarm 27
42#define __NR_oldfstat 28
43#define __NR_pause 29
44#define __NR_utime 30
45#define __NR_stty 31
46#define __NR_gtty 32
47#define __NR_access 33
48#define __NR_nice 34
49#define __NR_ftime 35
50#define __NR_sync 36
51#define __NR_kill 37
52#define __NR_rename 38
53#define __NR_mkdir 39
54#define __NR_rmdir 40
55#define __NR_dup 41
56#define __NR_pipe 42
57#define __NR_times 43
58#define __NR_prof 44
59#define __NR_brk 45
60#define __NR_setgid 46
61#define __NR_getgid 47
62#define __NR_signal 48
63#define __NR_geteuid 49
64#define __NR_getegid 50
65#define __NR_acct 51
66#define __NR_umount2 52
67#define __NR_lock 53
68#define __NR_ioctl 54
69#define __NR_fcntl 55
70#define __NR_mpx 56
71#define __NR_setpgid 57
72#define __NR_ulimit 58
73#define __NR_oldolduname 59
74#define __NR_umask 60
75#define __NR_chroot 61
76#define __NR_ustat 62
77#define __NR_dup2 63
78#define __NR_getppid 64
79#define __NR_getpgrp 65
80#define __NR_setsid 66
81#define __NR_sigaction 67
82#define __NR_sgetmask 68
83#define __NR_ssetmask 69
84#define __NR_setreuid 70
85#define __NR_setregid 71
86#define __NR_sigsuspend 72
87#define __NR_sigpending 73
88#define __NR_sethostname 74
89#define __NR_setrlimit 75
90#define __NR_getrlimit 76
91#define __NR_getrusage 77
92#define __NR_gettimeofday 78
93#define __NR_settimeofday 79
94#define __NR_getgroups 80
95#define __NR_setgroups 81
96#define __NR_select 82
97#define __NR_symlink 83
98#define __NR_oldlstat 84
99#define __NR_readlink 85
100#define __NR_uselib 86
101#define __NR_swapon 87
102#define __NR_reboot 88
103#define __NR_readdir 89
104#define __NR_mmap 90
105#define __NR_munmap 91
106#define __NR_truncate 92
107#define __NR_ftruncate 93
108#define __NR_fchmod 94
109#define __NR_fchown 95
110#define __NR_getpriority 96
111#define __NR_setpriority 97
112#define __NR_profil 98
113#define __NR_statfs 99
114#define __NR_fstatfs 100
115#define __NR_ioperm 101
116#define __NR_socketcall 102
117#define __NR_syslog 103
118#define __NR_setitimer 104
119#define __NR_getitimer 105
120#define __NR_stat 106
121#define __NR_lstat 107
122#define __NR_fstat 108
123#define __NR_olduname 109
124#define __NR_iopl 110
125#define __NR_vhangup 111
126#define __NR_idle 112
127#define __NR_vm86 113
128#define __NR_wait4 114
129#define __NR_swapoff 115
130#define __NR_sysinfo 116
131#define __NR_ipc 117
132#define __NR_fsync 118
133#define __NR_sigreturn 119
134#define __NR_clone 120
135#define __NR_setdomainname 121
136#define __NR_uname 122
137#define __NR_modify_ldt 123
138#define __NR_adjtimex 124
139#define __NR_mprotect 125
140#define __NR_sigprocmask 126
141#define __NR_create_module 127
142#define __NR_init_module 128
143#define __NR_delete_module 129
144#define __NR_get_kernel_syms 130
145#define __NR_quotactl 131
146#define __NR_getpgid 132
147#define __NR_fchdir 133
148#define __NR_bdflush 134
149#define __NR_sysfs 135
150#define __NR_personality 136
151#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
152#define __NR_setfsuid 138
153#define __NR_setfsgid 139
154#define __NR__llseek 140
155#define __NR_getdents 141
156#define __NR__newselect 142
157#define __NR_flock 143
158#define __NR_msync 144
159#define __NR_readv 145
160#define __NR_writev 146
161#define __NR_getsid 147
162#define __NR_fdatasync 148
163#define __NR__sysctl 149
164#define __NR_mlock 150
165#define __NR_munlock 151
166#define __NR_mlockall 152
167#define __NR_munlockall 153
168#define __NR_sched_setparam 154
169#define __NR_sched_getparam 155
170#define __NR_sched_setscheduler 156
171#define __NR_sched_getscheduler 157
172#define __NR_sched_yield 158
173#define __NR_sched_get_priority_max 159
174#define __NR_sched_get_priority_min 160
175#define __NR_sched_rr_get_interval 161
176#define __NR_nanosleep 162
177#define __NR_mremap 163
178#define __NR_setresuid 164
179#define __NR_getresuid 165
180#define __NR_query_module 166
181#define __NR_poll 167
182#define __NR_nfsservctl 168
183#define __NR_setresgid 169
184#define __NR_getresgid 170
185#define __NR_prctl 171
186#define __NR_rt_sigreturn 172
187#define __NR_rt_sigaction 173
188#define __NR_rt_sigprocmask 174
189#define __NR_rt_sigpending 175
190#define __NR_rt_sigtimedwait 176
191#define __NR_rt_sigqueueinfo 177
192#define __NR_rt_sigsuspend 178
193#define __NR_pread64 179
194#define __NR_pwrite64 180
195#define __NR_chown 181
196#define __NR_getcwd 182
197#define __NR_capget 183
198#define __NR_capset 184
199#define __NR_sigaltstack 185
200#define __NR_sendfile 186
201#define __NR_getpmsg 187 /* some people actually want streams */
202#define __NR_putpmsg 188 /* some people actually want streams */
203#define __NR_vfork 189
204#define __NR_ugetrlimit 190 /* SuS compliant getrlimit */
205#define __NR_readahead 191
206#ifndef __powerpc64__ /* these are 32-bit only */
207#define __NR_mmap2 192
208#define __NR_truncate64 193
209#define __NR_ftruncate64 194
210#define __NR_stat64 195
211#define __NR_lstat64 196
212#define __NR_fstat64 197
213#endif
214#define __NR_pciconfig_read 198
215#define __NR_pciconfig_write 199
216#define __NR_pciconfig_iobase 200
217#define __NR_multiplexer 201
218#define __NR_getdents64 202
219#define __NR_pivot_root 203
220#ifndef __powerpc64__
221#define __NR_fcntl64 204
222#endif
223#define __NR_madvise 205
224#define __NR_mincore 206
225#define __NR_gettid 207
226#define __NR_tkill 208
227#define __NR_setxattr 209
228#define __NR_lsetxattr 210
229#define __NR_fsetxattr 211
230#define __NR_getxattr 212
231#define __NR_lgetxattr 213
232#define __NR_fgetxattr 214
233#define __NR_listxattr 215
234#define __NR_llistxattr 216
235#define __NR_flistxattr 217
236#define __NR_removexattr 218
237#define __NR_lremovexattr 219
238#define __NR_fremovexattr 220
239#define __NR_futex 221
240#define __NR_sched_setaffinity 222
241#define __NR_sched_getaffinity 223
242/* 224 currently unused */
243#define __NR_tuxcall 225
244#ifndef __powerpc64__
245#define __NR_sendfile64 226
246#endif
247#define __NR_io_setup 227
248#define __NR_io_destroy 228
249#define __NR_io_getevents 229
250#define __NR_io_submit 230
251#define __NR_io_cancel 231
252#define __NR_set_tid_address 232
253#define __NR_fadvise64 233
254#define __NR_exit_group 234
255#define __NR_lookup_dcookie 235
256#define __NR_epoll_create 236
257#define __NR_epoll_ctl 237
258#define __NR_epoll_wait 238
259#define __NR_remap_file_pages 239
260#define __NR_timer_create 240
261#define __NR_timer_settime 241
262#define __NR_timer_gettime 242
263#define __NR_timer_getoverrun 243
264#define __NR_timer_delete 244
265#define __NR_clock_settime 245
266#define __NR_clock_gettime 246
267#define __NR_clock_getres 247
268#define __NR_clock_nanosleep 248
269#define __NR_swapcontext 249
270#define __NR_tgkill 250
271#define __NR_utimes 251
272#define __NR_statfs64 252
273#define __NR_fstatfs64 253
274#ifndef __powerpc64__
275#define __NR_fadvise64_64 254
276#endif
277#define __NR_rtas 255
278#define __NR_sys_debug_setcontext 256
279/* Number 257 is reserved for vserver */
280#define __NR_migrate_pages 258
281#define __NR_mbind 259
282#define __NR_get_mempolicy 260
283#define __NR_set_mempolicy 261
284#define __NR_mq_open 262
285#define __NR_mq_unlink 263
286#define __NR_mq_timedsend 264
287#define __NR_mq_timedreceive 265
288#define __NR_mq_notify 266
289#define __NR_mq_getsetattr 267
290#define __NR_kexec_load 268
291#define __NR_add_key 269
292#define __NR_request_key 270
293#define __NR_keyctl 271
294#define __NR_waitid 272
295#define __NR_ioprio_set 273
296#define __NR_ioprio_get 274
297#define __NR_inotify_init 275
298#define __NR_inotify_add_watch 276
299#define __NR_inotify_rm_watch 277
300#define __NR_spu_run 278
301#define __NR_spu_create 279
302#define __NR_pselect6 280
303#define __NR_ppoll 281
304#define __NR_unshare 282
305#define __NR_splice 283
306#define __NR_tee 284
307#define __NR_vmsplice 285
308#define __NR_openat 286
309#define __NR_mkdirat 287
310#define __NR_mknodat 288
311#define __NR_fchownat 289
312#define __NR_futimesat 290
313#ifdef __powerpc64__
314#define __NR_newfstatat 291
315#else
316#define __NR_fstatat64 291
317#endif
318#define __NR_unlinkat 292
319#define __NR_renameat 293
320#define __NR_linkat 294
321#define __NR_symlinkat 295
322#define __NR_readlinkat 296
323#define __NR_fchmodat 297
324#define __NR_faccessat 298
325#define __NR_get_robust_list 299
326#define __NR_set_robust_list 300
327#define __NR_move_pages 301
328#define __NR_getcpu 302
329#define __NR_epoll_pwait 303
330#define __NR_utimensat 304
331#define __NR_signalfd 305
332#define __NR_timerfd_create 306
333#define __NR_eventfd 307
334#define __NR_sync_file_range2 308
335#define __NR_fallocate 309
336#define __NR_subpage_prot 310
337#define __NR_timerfd_settime 311
338#define __NR_timerfd_gettime 312
339#define __NR_signalfd4 313
340#define __NR_eventfd2 314
341#define __NR_epoll_create1 315
342#define __NR_dup3 316
343#define __NR_pipe2 317
344#define __NR_inotify_init1 318
345#define __NR_perf_event_open 319
346#define __NR_preadv 320
347#define __NR_pwritev 321
348#define __NR_rt_tgsigqueueinfo 322
349#define __NR_fanotify_init 323
350#define __NR_fanotify_mark 324
351#define __NR_prlimit64 325
352#define __NR_socket 326
353#define __NR_bind 327
354#define __NR_connect 328
355#define __NR_listen 329
356#define __NR_accept 330
357#define __NR_getsockname 331
358#define __NR_getpeername 332
359#define __NR_socketpair 333
360#define __NR_send 334
361#define __NR_sendto 335
362#define __NR_recv 336
363#define __NR_recvfrom 337
364#define __NR_shutdown 338
365#define __NR_setsockopt 339
366#define __NR_getsockopt 340
367#define __NR_sendmsg 341
368#define __NR_recvmsg 342
369#define __NR_recvmmsg 343
370#define __NR_accept4 344
371#define __NR_name_to_handle_at 345
372#define __NR_open_by_handle_at 346
373#define __NR_clock_adjtime 347
374#define __NR_syncfs 348
375#define __NR_sendmmsg 349
376#define __NR_setns 350
377#define __NR_process_vm_readv 351
378#define __NR_process_vm_writev 352
379#define __NR_finit_module 353
380#define __NR_kcmp 354
381#define __NR_sched_setattr 355
382#define __NR_sched_getattr 356
383#define __NR_renameat2 357
384#define __NR_seccomp 358
385#define __NR_getrandom 359
386#define __NR_memfd_create 360
387#define __NR_bpf 361
388#define __NR_execveat 362
389#define __NR_switch_endian 363
390#define __NR_userfaultfd 364
391#define __NR_membarrier 365
392#define __NR_mlock2 378
393#define __NR_copy_file_range 379
394#define __NR_preadv2 380
395#define __NR_pwritev2 381
396#define __NR_kexec_file_load 382
397#define __NR_statx 383
398#define __NR_pkey_alloc 384
399#define __NR_pkey_free 385
400#define __NR_pkey_mprotect 386
401#define __NR_rseq 387
402#define __NR_io_pgetevents 388
403
404#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
libc/glibc/sysdeps/unix/sysv/linux/powerpc/bits/stat.h created+275
...@@ -0,0 +1,275 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <bits/wordsize.h>
26
27/* Versions of the `struct stat' data structure. */
28#define _STAT_VER_LINUX_OLD 1
29#define _STAT_VER_KERNEL 1
30#define _STAT_VER_SVR4 2
31#define _STAT_VER_LINUX 3
32#if __WORDSIZE == 32
33# define _STAT_VER _STAT_VER_LINUX
34#else
35# define _STAT_VER _STAT_VER_KERNEL
36#endif
37
38/* Versions of the `xmknod' interface. */
39#define _MKNOD_VER_LINUX 1
40#define _MKNOD_VER_SVR4 2
41#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
42
43
44#if __WORDSIZE == 32
45
46struct stat
47 {
48 __dev_t st_dev; /* Device. */
49# ifndef __USE_FILE_OFFSET64
50 unsigned short int __pad1;
51 __ino_t st_ino; /* File serial number. */
52# else
53 __ino64_t st_ino; /* File serial number. */
54# endif
55 __mode_t st_mode; /* File mode. */
56 __nlink_t st_nlink; /* Link count. */
57 __uid_t st_uid; /* User ID of the file's owner. */
58 __gid_t st_gid; /* Group ID of the file's group.*/
59 __dev_t st_rdev; /* Device number, if device. */
60 unsigned short int __pad2;
61# ifndef __USE_FILE_OFFSET64
62 __off_t st_size; /* Size of file, in bytes. */
63# else
64 __off64_t st_size; /* Size of file, in bytes. */
65# endif
66 __blksize_t st_blksize; /* Optimal block size for I/O. */
67
68# ifndef __USE_FILE_OFFSET64
69 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
70# else
71 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
72# endif
73# ifdef __USE_XOPEN2K8
74 /* Nanosecond resolution timestamps are stored in a format
75 equivalent to 'struct timespec'. This is the type used
76 whenever possible but the Unix namespace rules do not allow the
77 identifier 'timespec' to appear in the <sys/stat.h> header.
78 Therefore we have to handle the use of this header in strictly
79 standard-compliant sources special. */
80 struct timespec st_atim; /* Time of last access. */
81 struct timespec st_mtim; /* Time of last modification. */
82 struct timespec st_ctim; /* Time of last status change. */
83# define st_atime st_atim.tv_sec /* Backward compatibility. */
84# define st_mtime st_mtim.tv_sec
85# define st_ctime st_ctim.tv_sec
86# else
87 __time_t st_atime; /* Time of last access. */
88 unsigned long int st_atimensec; /* Nscecs of last access. */
89 __time_t st_mtime; /* Time of last modification. */
90 unsigned long int st_mtimensec; /* Nsecs of last modification. */
91 __time_t st_ctime; /* Time of last status change. */
92 unsigned long int st_ctimensec; /* Nsecs of last status change. */
93# endif
94 unsigned long int __glibc_reserved4;
95 unsigned long int __glibc_reserved5;
96 };
97
98
99# ifdef __USE_LARGEFILE64
100struct stat64
101 {
102 __dev_t st_dev; /* Device. */
103 __ino64_t st_ino; /* File serial number. */
104 __mode_t st_mode; /* File mode. */
105 __nlink_t st_nlink; /* Link count. */
106 __uid_t st_uid; /* User ID of the file's owner. */
107 __gid_t st_gid; /* Group ID of the file's group.*/
108 __dev_t st_rdev; /* Device number, if device. */
109 unsigned short int __pad2;
110 __off64_t st_size; /* Size of file, in bytes. */
111 __blksize_t st_blksize; /* Optimal block size for I/O. */
112 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
113# ifdef __USE_XOPEN2K8
114 /* Nanosecond resolution timestamps are stored in a format
115 equivalent to 'struct timespec'. This is the type used
116 whenever possible but the Unix namespace rules do not allow the
117 identifier 'timespec' to appear in the <sys/stat.h> header.
118 Therefore we have to handle the use of this header in strictly
119 standard-compliant sources special. */
120 struct timespec st_atim; /* Time of last access. */
121 struct timespec st_mtim; /* Time of last modification. */
122 struct timespec st_ctim; /* Time of last status change. */
123# define st_atime st_atim.tv_sec /* Backward compatibility. */
124# define st_mtime st_mtim.tv_sec
125# define st_ctime st_ctim.tv_sec
126# else
127 __time_t st_atime; /* Time of last access. */
128 unsigned long int st_atimensec; /* Nscecs of last access. */
129 __time_t st_mtime; /* Time of last modification. */
130 unsigned long int st_mtimensec; /* Nsecs of last modification. */
131 __time_t st_ctime; /* Time of last status change. */
132 unsigned long int st_ctimensec; /* Nsecs of last status change. */
133# endif
134 unsigned long int __glibc_reserved4;
135 unsigned long int __glibc_reserved5;
136 };
137# endif /* __USE_LARGEFILE64 */
138
139#else /* __WORDSIZE == 32 */
140
141struct stat
142 {
143 __dev_t st_dev; /* Device. */
144# ifndef __USE_FILE_OFFSET64
145 __ino_t st_ino; /* File serial number. */
146# else
147 __ino64_t st_ino; /* File serial number. */
148# endif
149 __nlink_t st_nlink; /* Link count. */
150 __mode_t st_mode; /* File mode. */
151 __uid_t st_uid; /* User ID of the file's owner. */
152 __gid_t st_gid; /* Group ID of the file's group.*/
153 int __pad2;
154 __dev_t st_rdev; /* Device number, if device. */
155# ifndef __USE_FILE_OFFSET64
156 __off_t st_size; /* Size of file, in bytes. */
157# else
158 __off64_t st_size; /* Size of file, in bytes. */
159# endif
160 __blksize_t st_blksize; /* Optimal block size for I/O. */
161
162# ifndef __USE_FILE_OFFSET64
163 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
164# else
165 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
166# endif
167# ifdef __USE_XOPEN2K8
168 /* Nanosecond resolution timestamps are stored in a format
169 equivalent to 'struct timespec'. This is the type used
170 whenever possible but the Unix namespace rules do not allow the
171 identifier 'timespec' to appear in the <sys/stat.h> header.
172 Therefore we have to handle the use of this header in strictly
173 standard-compliant sources special. */
174 struct timespec st_atim; /* Time of last access. */
175 struct timespec st_mtim; /* Time of last modification. */
176 struct timespec st_ctim; /* Time of last status change. */
177# define st_atime st_atim.tv_sec /* Backward compatibility. */
178# define st_mtime st_mtim.tv_sec
179# define st_ctime st_ctim.tv_sec
180# else
181 __time_t st_atime; /* Time of last access. */
182 unsigned long int st_atimensec; /* Nscecs of last access. */
183 __time_t st_mtime; /* Time of last modification. */
184 unsigned long int st_mtimensec; /* Nsecs of last modification. */
185 __time_t st_ctime; /* Time of last status change. */
186 unsigned long int st_ctimensec; /* Nsecs of last status change. */
187# endif
188 unsigned long int __glibc_reserved4;
189 unsigned long int __glibc_reserved5;
190 unsigned long int __glibc_reserved6;
191 };
192
193# ifdef __USE_LARGEFILE64
194struct stat64
195 {
196 __dev_t st_dev; /* Device. */
197 __ino64_t st_ino; /* File serial number. */
198 __nlink_t st_nlink; /* Link count. */
199 __mode_t st_mode; /* File mode. */
200 __uid_t st_uid; /* User ID of the file's owner. */
201 __gid_t st_gid; /* Group ID of the file's group.*/
202 int __pad2;
203 __dev_t st_rdev; /* Device number, if device. */
204 __off64_t st_size; /* Size of file, in bytes. */
205 __blksize_t st_blksize; /* Optimal block size for I/O. */
206 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
207# ifdef __USE_XOPEN2K8
208 /* Nanosecond resolution timestamps are stored in a format
209 equivalent to 'struct timespec'. This is the type used
210 whenever possible but the Unix namespace rules do not allow the
211 identifier 'timespec' to appear in the <sys/stat.h> header.
212 Therefore we have to handle the use of this header in strictly
213 standard-compliant sources special. */
214 struct timespec st_atim; /* Time of last access. */
215 struct timespec st_mtim; /* Time of last modification. */
216 struct timespec st_ctim; /* Time of last status change. */
217# define st_atime st_atim.tv_sec /* Backward compatibility. */
218# define st_mtime st_mtim.tv_sec
219# define st_ctime st_ctim.tv_sec
220# else
221 __time_t st_atime; /* Time of last access. */
222 unsigned long int st_atimensec; /* Nscecs of last access. */
223 __time_t st_mtime; /* Time of last modification. */
224 unsigned long int st_mtimensec; /* Nsecs of last modification. */
225 __time_t st_ctime; /* Time of last status change. */
226 unsigned long int st_ctimensec; /* Nsecs of last status change. */
227# endif
228 unsigned long int __glibc_reserved4;
229 unsigned long int __glibc_reserved5;
230 unsigned long int __glibc_reserved6;
231 };
232# endif /* __USE_LARGEFILE64 */
233#endif
234
235
236/* Tell code we have these members. */
237#define _STATBUF_ST_BLKSIZE
238#define _STATBUF_ST_RDEV
239/* Nanosecond resolution time values are supported. */
240#define _STATBUF_ST_NSEC
241
242/* Encoding of the file mode. */
243
244#define __S_IFMT 0170000 /* These bits determine file type. */
245
246/* File types. */
247#define __S_IFDIR 0040000 /* Directory. */
248#define __S_IFCHR 0020000 /* Character device. */
249#define __S_IFBLK 0060000 /* Block device. */
250#define __S_IFREG 0100000 /* Regular file. */
251#define __S_IFIFO 0010000 /* FIFO. */
252#define __S_IFLNK 0120000 /* Symbolic link. */
253#define __S_IFSOCK 0140000 /* Socket. */
254
255/* POSIX.1b objects. Note that these macros always evaluate to zero. But
256 they do it by enforcing the correct use of the macros. */
257#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
258#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
259#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
260
261/* Protection bits. */
262
263#define __S_ISUID 04000 /* Set user ID on execution. */
264#define __S_ISGID 02000 /* Set group ID on execution. */
265#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
266#define __S_IREAD 0400 /* Read by owner. */
267#define __S_IWRITE 0200 /* Write by owner. */
268#define __S_IEXEC 0100 /* Execute by owner. */
269
270#ifdef __USE_ATFILE
271# define UTIME_NOW ((1l << 30) - 1l)
272# define UTIME_OMIT ((1l << 30) - 2l)
273#endif
274
275#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/powerpc/kernel-features.h created+51
...@@ -0,0 +1,51 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. PowerPC version.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* New syscalls added for PowerPC in 2.6.37. */
21#define __ASSUME_SOCKET_SYSCALL 1
22#define __ASSUME_BIND_SYSCALL 1
23#define __ASSUME_CONNECT_SYSCALL 1
24#define __ASSUME_LISTEN_SYSCALL 1
25#define __ASSUME_GETSOCKNAME_SYSCALL 1
26#define __ASSUME_GETPEERNAME_SYSCALL 1
27#define __ASSUME_SOCKETPAIR_SYSCALL 1
28#define __ASSUME_SEND_SYSCALL 1
29#define __ASSUME_RECV_SYSCALL 1
30#define __ASSUME_SHUTDOWN_SYSCALL 1
31#define __ASSUME_GETSOCKOPT_SYSCALL 1
32#define __ASSUME_SETSOCKOPT_SYSCALL 1
33
34/* Define this if your 32-bit syscall API requires 64-bit register
35 pairs to start with an even-number register. */
36#ifndef __powerpc64__
37# define __ASSUME_ALIGNED_REGISTER_PAIRS 1
38#endif
39
40/* powerpc compat fadvise64_64 reorganize the syscall argument. */
41#ifndef __powerpc64__
42# define __ASSUME_FADVISE64_64_6ARG 1
43#endif
44
45#include_next <kernel-features.h>
46
47/* powerpc only supports ipc syscall. */
48#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
49
50#undef __ASSUME_CLONE_DEFAULT
51#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h created+236
...@@ -0,0 +1,236 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_POWERPC_SYSDEP_H
19#define _LINUX_POWERPC_SYSDEP_H 1
20
21/* Always enable vsyscalls on powerpc32 */
22#define ALWAYS_USE_VSYSCALL 1
23
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <sysdeps/unix/powerpc/sysdep.h>
26#include <tls.h>
27
28/* For Linux we can use the system call table in the header file
29 /usr/include/asm/unistd.h
30 of the kernel. But these symbols do not follow the SYS_* syntax
31 so we have to redefine the `SYS_ify' macro here. */
32#undef SYS_ify
33#define SYS_ify(syscall_name) __NR_##syscall_name
34
35#ifndef __ASSEMBLER__
36
37# include <errno.h>
38
39/* Define a macro which expands inline into the wrapper code for a VDSO
40 call. This use is for internal calls that do not need to handle errors
41 normally. It will never touch errno.
42 On powerpc a system call basically clobbers the same registers like a
43 function call, with the exception of LR (which is needed for the
44 "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
45 an error return status). */
46# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, type, args...) \
47 ({ \
48 register void *r0 __asm__ ("r0"); \
49 register long int r3 __asm__ ("r3"); \
50 register long int r4 __asm__ ("r4"); \
51 register long int r5 __asm__ ("r5"); \
52 register long int r6 __asm__ ("r6"); \
53 register long int r7 __asm__ ("r7"); \
54 register long int r8 __asm__ ("r8"); \
55 register long int r9 __asm__ ("r9"); \
56 register long int r10 __asm__ ("r10"); \
57 register long int r11 __asm__ ("r11"); \
58 register long int r12 __asm__ ("r12"); \
59 register type rval __asm__ ("r3"); \
60 LOADARGS_##nr (funcptr, args); \
61 __asm__ __volatile__ \
62 ("mtctr %0\n\t" \
63 "bctrl\n\t" \
64 "mfcr %0" \
65 : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), "+r" (r7), \
66 "+r" (r8), "+r" (r9), "+r" (r10), "+r" (r11), "+r" (r12) \
67 : : "cr0", "ctr", "lr", "memory"); \
68 err = (long int) r0; \
69 __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3), "r" (r4)); \
70 rval; \
71 })
72
73#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
74 INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, long int, args)
75
76# undef INLINE_SYSCALL
77# define INLINE_SYSCALL(name, nr, args...) \
78 ({ \
79 INTERNAL_SYSCALL_DECL (sc_err); \
80 long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
81 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
82 { \
83 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
84 sc_ret = -1L; \
85 } \
86 sc_ret; \
87 })
88
89/* Define a macro which expands inline into the wrapper code for a system
90 call. This use is for internal calls that do not need to handle errors
91 normally. It will never touch errno.
92 On powerpc a system call basically clobbers the same registers like a
93 function call, with the exception of LR (which is needed for the
94 "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
95 an error return status). */
96
97# undef INTERNAL_SYSCALL_DECL
98# define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
99
100# undef INTERNAL_SYSCALL
101# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
102 ({ \
103 register long int r0 __asm__ ("r0"); \
104 register long int r3 __asm__ ("r3"); \
105 register long int r4 __asm__ ("r4"); \
106 register long int r5 __asm__ ("r5"); \
107 register long int r6 __asm__ ("r6"); \
108 register long int r7 __asm__ ("r7"); \
109 register long int r8 __asm__ ("r8"); \
110 register long int r9 __asm__ ("r9"); \
111 register long int r10 __asm__ ("r10"); \
112 register long int r11 __asm__ ("r11"); \
113 register long int r12 __asm__ ("r12"); \
114 LOADARGS_##nr(name, args); \
115 __asm__ __volatile__ \
116 ("sc \n\t" \
117 "mfcr %0" \
118 : "=&r" (r0), \
119 "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
120 "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
121 : ASM_INPUT_##nr \
122 : "cr0", "ctr", "memory"); \
123 err = r0; \
124 (int) r3; \
125 })
126# define INTERNAL_SYSCALL(name, err, nr, args...) \
127 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
128
129# undef INTERNAL_SYSCALL_ERROR_P
130# define INTERNAL_SYSCALL_ERROR_P(val, err) \
131 ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
132
133# undef INTERNAL_SYSCALL_ERRNO
134# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
135
136# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...) \
137 ({ \
138 type sc_ret = ENOSYS; \
139 \
140 __typeof (__vdso_##name) vdsop = __vdso_##name; \
141 PTR_DEMANGLE (vdsop); \
142 if (vdsop != NULL) \
143 sc_ret = \
144 INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, nr, type, ##args); \
145 else \
146 err = 1 << 28; \
147 sc_ret; \
148 })
149
150/* List of system calls which are supported as vsyscalls. */
151# define HAVE_CLOCK_GETRES_VSYSCALL 1
152# define HAVE_CLOCK_GETTIME_VSYSCALL 1
153# define HAVE_GETCPU_VSYSCALL 1
154
155
156# define LOADARGS_0(name, dummy) \
157 r0 = name
158# define LOADARGS_1(name, __arg1) \
159 long int arg1 = (long int) (__arg1); \
160 LOADARGS_0(name, 0); \
161 extern void __illegally_sized_syscall_arg1 (void); \
162 if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
163 __illegally_sized_syscall_arg1 (); \
164 r3 = arg1
165# define LOADARGS_2(name, __arg1, __arg2) \
166 long int arg2 = (long int) (__arg2); \
167 LOADARGS_1(name, __arg1); \
168 extern void __illegally_sized_syscall_arg2 (void); \
169 if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
170 __illegally_sized_syscall_arg2 (); \
171 r4 = arg2
172# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
173 long int arg3 = (long int) (__arg3); \
174 LOADARGS_2(name, __arg1, __arg2); \
175 extern void __illegally_sized_syscall_arg3 (void); \
176 if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
177 __illegally_sized_syscall_arg3 (); \
178 r5 = arg3
179# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
180 long int arg4 = (long int) (__arg4); \
181 LOADARGS_3(name, __arg1, __arg2, __arg3); \
182 extern void __illegally_sized_syscall_arg4 (void); \
183 if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
184 __illegally_sized_syscall_arg4 (); \
185 r6 = arg4
186# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
187 long int arg5 = (long int) (__arg5); \
188 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
189 extern void __illegally_sized_syscall_arg5 (void); \
190 if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
191 __illegally_sized_syscall_arg5 (); \
192 r7 = arg5
193# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
194 long int arg6 = (long int) (__arg6); \
195 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
196 extern void __illegally_sized_syscall_arg6 (void); \
197 if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
198 __illegally_sized_syscall_arg6 (); \
199 r8 = arg6
200
201# define ASM_INPUT_0 "0" (r0)
202# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
203# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
204# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
205# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
206# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
207# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
208
209#endif /* __ASSEMBLER__ */
210
211
212/* Pointer mangling support. */
213#if IS_IN (rtld)
214/* We cannot use the thread descriptor because in ld.so we use setjmp
215 earlier than the descriptor is initialized. */
216#else
217# ifdef __ASSEMBLER__
218# define PTR_MANGLE(reg, tmpreg) \
219 lwz tmpreg,POINTER_GUARD(r2); \
220 xor reg,tmpreg,reg
221# define PTR_MANGLE2(reg, tmpreg) \
222 xor reg,tmpreg,reg
223# define PTR_MANGLE3(destreg, reg, tmpreg) \
224 lwz tmpreg,POINTER_GUARD(r2); \
225 xor destreg,tmpreg,reg
226# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
227# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
228# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
229# else
230# define PTR_MANGLE(var) \
231 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
232# define PTR_DEMANGLE(var) PTR_MANGLE (var)
233# endif
234#endif
235
236#endif /* linux/powerpc/powerpc32/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h created+250
...@@ -0,0 +1,250 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Alan Modra <amodra@bigpond.net.au> rewrote the INLINE_SYSCALL macro */
19
20#ifndef _LINUX_POWERPC_SYSDEP_H
21#define _LINUX_POWERPC_SYSDEP_H 1
22
23/* Always enable vsyscalls on powerpc64 */
24#define ALWAYS_USE_VSYSCALL 1
25
26#include <sysdeps/unix/sysv/linux/sysdep.h>
27#include <sysdeps/unix/powerpc/sysdep.h>
28#include <tls.h>
29
30/* Define __set_errno() for INLINE_SYSCALL macro below. */
31#ifndef __ASSEMBLER__
32#include <errno.h>
33#endif
34
35/* For Linux we can use the system call table in the header file
36 /usr/include/asm/unistd.h
37 of the kernel. But these symbols do not follow the SYS_* syntax
38 so we have to redefine the `SYS_ify' macro here. */
39#undef SYS_ify
40#define SYS_ify(syscall_name) __NR_##syscall_name
41
42#ifdef __ASSEMBLER__
43
44/* This seems to always be the case on PPC. */
45# define ALIGNARG(log2) log2
46# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
47
48#endif /* __ASSEMBLER__ */
49
50/* This version is for internal uses when there is no desire
51 to set errno */
52#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...) \
53 ({ \
54 type sc_ret = ENOSYS; \
55 \
56 __typeof (__vdso_##name) vdsop = __vdso_##name; \
57 PTR_DEMANGLE (vdsop); \
58 if (vdsop != NULL) \
59 sc_ret = \
60 INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, type, nr, ##args); \
61 else \
62 err = 1 << 28; \
63 sc_ret; \
64 })
65
66/* List of system calls which are supported as vsyscalls. */
67#define HAVE_CLOCK_GETRES_VSYSCALL 1
68#define HAVE_CLOCK_GETTIME_VSYSCALL 1
69#define HAVE_GETCPU_VSYSCALL 1
70
71/* Define a macro which expands inline into the wrapper code for a system
72 call. This use is for internal calls that do not need to handle errors
73 normally. It will never touch errno. This returns just what the kernel
74 gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
75 the negation of the return value in the kernel gets reverted. */
76
77#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...) \
78 ({ \
79 register void *r0 __asm__ ("r0"); \
80 register long int r3 __asm__ ("r3"); \
81 register long int r4 __asm__ ("r4"); \
82 register long int r5 __asm__ ("r5"); \
83 register long int r6 __asm__ ("r6"); \
84 register long int r7 __asm__ ("r7"); \
85 register long int r8 __asm__ ("r8"); \
86 register type rval __asm__ ("r3"); \
87 LOADARGS_##nr (funcptr, args); \
88 __asm__ __volatile__ \
89 ("mtctr %0\n\t" \
90 "bctrl\n\t" \
91 "mfcr %0\n\t" \
92 "0:" \
93 : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), \
94 "+r" (r7), "+r" (r8) \
95 : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory"); \
96 err = (long int) r0; \
97 __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3)); \
98 rval; \
99 })
100
101#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
102 INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
103
104#undef INLINE_SYSCALL
105
106/* This version is for kernels that implement system calls that
107 behave like function calls as far as register saving. */
108#define INLINE_SYSCALL(name, nr, args...) \
109 ({ \
110 INTERNAL_SYSCALL_DECL (sc_err); \
111 long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
112 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
113 { \
114 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
115 sc_ret = -1L; \
116 } \
117 sc_ret; \
118 })
119
120/* Define a macro which expands inline into the wrapper code for a system
121 call. This use is for internal calls that do not need to handle errors
122 normally. It will never touch errno. This returns just what the kernel
123 gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
124 the negation of the return value in the kernel gets reverted. */
125
126#undef INTERNAL_SYSCALL
127#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
128 ({ \
129 register long int r0 __asm__ ("r0"); \
130 register long int r3 __asm__ ("r3"); \
131 register long int r4 __asm__ ("r4"); \
132 register long int r5 __asm__ ("r5"); \
133 register long int r6 __asm__ ("r6"); \
134 register long int r7 __asm__ ("r7"); \
135 register long int r8 __asm__ ("r8"); \
136 LOADARGS_##nr (name, ##args); \
137 __asm__ __volatile__ \
138 ("sc\n\t" \
139 "mfcr %0\n\t" \
140 "0:" \
141 : "=&r" (r0), \
142 "=&r" (r3), "=&r" (r4), "=&r" (r5), \
143 "=&r" (r6), "=&r" (r7), "=&r" (r8) \
144 : ASM_INPUT_##nr \
145 : "r9", "r10", "r11", "r12", \
146 "cr0", "ctr", "memory"); \
147 err = r0; \
148 r3; \
149 })
150#define INTERNAL_SYSCALL(name, err, nr, args...) \
151 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
152
153#undef INTERNAL_SYSCALL_DECL
154#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
155
156#undef INTERNAL_SYSCALL_ERROR_P
157#define INTERNAL_SYSCALL_ERROR_P(val, err) \
158 ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
159
160#undef INTERNAL_SYSCALL_ERRNO
161#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
162
163#define LOADARGS_0(name, dummy) \
164 r0 = name
165#define LOADARGS_1(name, __arg1) \
166 long int arg1 = (long int) (__arg1); \
167 LOADARGS_0(name, 0); \
168 extern void __illegally_sized_syscall_arg1 (void); \
169 if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 8) \
170 __illegally_sized_syscall_arg1 (); \
171 r3 = arg1
172#define LOADARGS_2(name, __arg1, __arg2) \
173 long int arg2 = (long int) (__arg2); \
174 LOADARGS_1(name, __arg1); \
175 extern void __illegally_sized_syscall_arg2 (void); \
176 if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 8) \
177 __illegally_sized_syscall_arg2 (); \
178 r4 = arg2
179#define LOADARGS_3(name, __arg1, __arg2, __arg3) \
180 long int arg3 = (long int) (__arg3); \
181 LOADARGS_2(name, __arg1, __arg2); \
182 extern void __illegally_sized_syscall_arg3 (void); \
183 if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 8) \
184 __illegally_sized_syscall_arg3 (); \
185 r5 = arg3
186#define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
187 long int arg4 = (long int) (__arg4); \
188 LOADARGS_3(name, __arg1, __arg2, __arg3); \
189 extern void __illegally_sized_syscall_arg4 (void); \
190 if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 8) \
191 __illegally_sized_syscall_arg4 (); \
192 r6 = arg4
193#define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
194 long int arg5 = (long int) (__arg5); \
195 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
196 extern void __illegally_sized_syscall_arg5 (void); \
197 if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 8) \
198 __illegally_sized_syscall_arg5 (); \
199 r7 = arg5
200#define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
201 long int arg6 = (long int) (__arg6); \
202 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
203 extern void __illegally_sized_syscall_arg6 (void); \
204 if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 8) \
205 __illegally_sized_syscall_arg6 (); \
206 r8 = arg6
207
208#define ASM_INPUT_0 "0" (r0)
209#define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
210#define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
211#define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
212#define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
213#define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
214#define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
215
216
217/* Pointer mangling support. */
218#if IS_IN (rtld)
219/* We cannot use the thread descriptor because in ld.so we use setjmp
220 earlier than the descriptor is initialized. */
221#else
222# ifdef __ASSEMBLER__
223# define PTR_MANGLE(reg, tmpreg) \
224 ld tmpreg,POINTER_GUARD(r13); \
225 xor reg,tmpreg,reg
226# define PTR_MANGLE2(reg, tmpreg) \
227 xor reg,tmpreg,reg
228# define PTR_MANGLE3(destreg, reg, tmpreg) \
229 ld tmpreg,POINTER_GUARD(r13); \
230 xor destreg,tmpreg,reg
231# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
232# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
233# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
234# else
235# define PTR_MANGLE(var) \
236 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
237# define PTR_DEMANGLE(var) PTR_MANGLE (var)
238# endif
239#endif
240
241/* In the PowerPC64 ABI, the unadorned F_GETLK* opcodes should be used
242 even by largefile64 code. */
243#define FCNTL_ADJUST_CMD(__cmd) \
244 ({ int cmd_ = (__cmd); \
245 if (cmd_ >= F_GETLK64 && cmd_ <= F_SETLKW64) \
246 cmd_ -= F_GETLK64 - F_GETLK; \
247 cmd_; })
248
249
250#endif /* linux/powerpc/powerpc64/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/riscv/asm/unistd.h created+41
...@@ -0,0 +1,41 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * Copyright (C) 2018 David Abdurachmanov <david.abdurachmanov@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifdef __LP64__
19#define __ARCH_WANT_NEW_STAT
20#endif /* __LP64__ */
21
22#include <asm-generic/unistd.h>
23
24/*
25 * Allows the instruction cache to be flushed from userspace. Despite RISC-V
26 * having a direct 'fence.i' instruction available to userspace (which we
27 * can't trap!), that's not actually viable when running on Linux because the
28 * kernel might schedule a process on another hart. There is no way for
29 * userspace to handle this without invoking the kernel (as it doesn't know the
30 * thread->hart mappings), so we've defined a RISC-V specific system call to
31 * flush the instruction cache.
32 *
33 * __NR_riscv_flush_icache is defined to flush the instruction cache over an
34 * address range, with the flush applying to either all threads or just the
35 * caller. We don't currently do anything with the address range, that's just
36 * in there for forwards compatibility.
37 */
38#ifndef __NR_riscv_flush_icache
39#define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15)
40#endif
41__SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache)
libc/glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h created+28
...@@ -0,0 +1,28 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. RISC-V version.
3 Copyright (C) 2018-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include_next <kernel-features.h>
21
22#undef __ASSUME_CLONE_DEFAULT
23#define __ASSUME_CLONE_BACKWARDS 1
24
25/* No support for PI mutexes or robust futexes before 4.20. */
26#if __LINUX_KERNEL_VERSION < 0x041400
27# undef __ASSUME_SET_ROBUST_LIST
28#endif
libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h created+325
...@@ -0,0 +1,325 @@
1/* Assembly macros for RISC-V.
2 Copyright (C) 2011-2018
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_RISCV_SYSDEP_H
20#define _LINUX_RISCV_SYSDEP_H 1
21
22#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
23#include <tls.h>
24
25#ifdef __ASSEMBLER__
26
27# include <sys/asm.h>
28
29# define ENTRY(name) LEAF(name)
30
31# define L(label) .L ## label
32
33/* Performs a system call, handling errors by setting errno. Linux indicates
34 errors by setting a0 to a value between -1 and -4095. */
35# undef PSEUDO
36# define PSEUDO(name, syscall_name, args) \
37 .text; \
38 .align 2; \
39 ENTRY (name); \
40 li a7, SYS_ify (syscall_name); \
41 scall; \
42 li a7, -4096; \
43 bgtu a0, a7, .Lsyscall_error ## name;
44
45# undef PSEUDO_END
46# define PSEUDO_END(sym) \
47 SYSCALL_ERROR_HANDLER (sym) \
48 ret; \
49 END (sym)
50
51# if !IS_IN (libc)
52# if RTLD_PRIVATE_ERRNO
53# define SYSCALL_ERROR_HANDLER(name) \
54.Lsyscall_error ## name: \
55 li t1, -4096; \
56 neg a0, a0; \
57 sw a0, rtld_errno, t1; \
58 li a0, -1;
59# elif defined (__PIC__)
60# define SYSCALL_ERROR_HANDLER(name) \
61.Lsyscall_error ## name: \
62 la.tls.ie t1, errno; \
63 add t1, t1, tp; \
64 neg a0, a0; \
65 sw a0, 0(t1); \
66 li a0, -1;
67# else
68# define SYSCALL_ERROR_HANDLER(name) \
69.Lsyscall_error ## name: \
70 lui t1, %tprel_hi(errno); \
71 add t1, t1, tp, %tprel_add(errno); \
72 neg a0, a0; \
73 sw a0, %tprel_lo(errno)(t1); \
74 li a0, -1;
75# endif
76# else
77# define SYSCALL_ERROR_HANDLER(name) \
78.Lsyscall_error ## name: \
79 j __syscall_error;
80# endif
81
82/* Performs a system call, not setting errno. */
83# undef PSEUDO_NEORRNO
84# define PSEUDO_NOERRNO(name, syscall_name, args) \
85 .align 2; \
86 ENTRY (name); \
87 li a7, SYS_ify (syscall_name); \
88 scall;
89
90# undef PSEUDO_END_NOERRNO
91# define PSEUDO_END_NOERRNO(name) \
92 END (name)
93
94# undef ret_NOERRNO
95# define ret_NOERRNO ret
96
97/* Perfroms a system call, returning the error code. */
98# undef PSEUDO_ERRVAL
99# define PSEUDO_ERRVAL(name, syscall_name, args) \
100 PSEUDO_NOERRNO (name, syscall_name, args) \
101 neg a0, a0;
102
103# undef PSEUDO_END_ERRVAL
104# define PSEUDO_END_ERRVAL(name) \
105 END (name)
106
107# undef ret_ERRVAL
108# define ret_ERRVAL ret
109
110#endif /* __ASSEMBLER__ */
111
112/* In order to get __set_errno() definition in INLINE_SYSCALL. */
113#ifndef __ASSEMBLER__
114# include <errno.h>
115#endif
116
117#include <sysdeps/unix/sysdep.h>
118
119#undef SYS_ify
120#define SYS_ify(syscall_name) __NR_##syscall_name
121
122#ifndef __ASSEMBLER__
123
124/* List of system calls which are supported as vsyscalls. */
125# define HAVE_CLOCK_GETRES_VSYSCALL 1
126# define HAVE_CLOCK_GETTIME_VSYSCALL 1
127# define HAVE_GETTIMEOFDAY_VSYSCALL 1
128# define HAVE_GETCPU_VSYSCALL 1
129
130/* Define a macro which expands into the inline wrapper code for a system
131 call. */
132# undef INLINE_SYSCALL
133# define INLINE_SYSCALL(name, nr, args...) \
134 ({ INTERNAL_SYSCALL_DECL (err); \
135 long int __sys_result = INTERNAL_SYSCALL (name, err, nr, args); \
136 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_result, ))) \
137 { \
138 __set_errno (INTERNAL_SYSCALL_ERRNO (__sys_result, )); \
139 __sys_result = (unsigned long) -1; \
140 } \
141 __sys_result; })
142
143# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
144
145# define INTERNAL_SYSCALL_ERROR_P(val, err) \
146 ((unsigned long int) (val) > -4096UL)
147
148# define INTERNAL_SYSCALL_ERRNO(val, err) (-val)
149
150# define INTERNAL_SYSCALL(name, err, nr, args...) \
151 internal_syscall##nr (SYS_ify (name), err, args)
152
153# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
154 internal_syscall##nr (number, err, args)
155
156# define internal_syscall0(number, err, dummy...) \
157({ \
158 long int _sys_result; \
159 \
160 { \
161 register long int __a7 asm ("a7") = number; \
162 register long int __a0 asm ("a0"); \
163 __asm__ volatile ( \
164 "scall\n\t" \
165 : "=r" (__a0) \
166 : "r" (__a7) \
167 : __SYSCALL_CLOBBERS); \
168 _sys_result = __a0; \
169 } \
170 _sys_result; \
171})
172
173# define internal_syscall1(number, err, arg0) \
174({ \
175 long int _sys_result; \
176 \
177 { \
178 register long int __a7 asm ("a7") = number; \
179 register long int __a0 asm ("a0") = (long int) (arg0); \
180 __asm__ volatile ( \
181 "scall\n\t" \
182 : "+r" (__a0) \
183 : "r" (__a7) \
184 : __SYSCALL_CLOBBERS); \
185 _sys_result = __a0; \
186 } \
187 _sys_result; \
188})
189
190# define internal_syscall2(number, err, arg0, arg1) \
191({ \
192 long int _sys_result; \
193 \
194 { \
195 register long int __a7 asm ("a7") = number; \
196 register long int __a0 asm ("a0") = (long int) (arg0); \
197 register long int __a1 asm ("a1") = (long int) (arg1); \
198 __asm__ volatile ( \
199 "scall\n\t" \
200 : "+r" (__a0) \
201 : "r" (__a7), "r" (__a1) \
202 : __SYSCALL_CLOBBERS); \
203 _sys_result = __a0; \
204 } \
205 _sys_result; \
206})
207
208# define internal_syscall3(number, err, arg0, arg1, arg2) \
209({ \
210 long int _sys_result; \
211 \
212 { \
213 register long int __a7 asm ("a7") = number; \
214 register long int __a0 asm ("a0") = (long int) (arg0); \
215 register long int __a1 asm ("a1") = (long int) (arg1); \
216 register long int __a2 asm ("a2") = (long int) (arg2); \
217 __asm__ volatile ( \
218 "scall\n\t" \
219 : "+r" (__a0) \
220 : "r" (__a7), "r" (__a1), "r" (__a2) \
221 : __SYSCALL_CLOBBERS); \
222 _sys_result = __a0; \
223 } \
224 _sys_result; \
225})
226
227# define internal_syscall4(number, err, arg0, arg1, arg2, arg3) \
228({ \
229 long int _sys_result; \
230 \
231 { \
232 register long int __a7 asm ("a7") = number; \
233 register long int __a0 asm ("a0") = (long int) (arg0); \
234 register long int __a1 asm ("a1") = (long int) (arg1); \
235 register long int __a2 asm ("a2") = (long int) (arg2); \
236 register long int __a3 asm ("a3") = (long int) (arg3); \
237 __asm__ volatile ( \
238 "scall\n\t" \
239 : "+r" (__a0) \
240 : "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3) \
241 : __SYSCALL_CLOBBERS); \
242 _sys_result = __a0; \
243 } \
244 _sys_result; \
245})
246
247# define internal_syscall5(number, err, arg0, arg1, arg2, arg3, arg4) \
248({ \
249 long int _sys_result; \
250 \
251 { \
252 register long int __a7 asm ("a7") = number; \
253 register long int __a0 asm ("a0") = (long int) (arg0); \
254 register long int __a1 asm ("a1") = (long int) (arg1); \
255 register long int __a2 asm ("a2") = (long int) (arg2); \
256 register long int __a3 asm ("a3") = (long int) (arg3); \
257 register long int __a4 asm ("a4") = (long int) (arg4); \
258 __asm__ volatile ( \
259 "scall\n\t" \
260 : "+r" (__a0) \
261 : "r" (__a7), "r"(__a1), "r"(__a2), "r"(__a3), "r" (__a4) \
262 : __SYSCALL_CLOBBERS); \
263 _sys_result = __a0; \
264 } \
265 _sys_result; \
266})
267
268# define internal_syscall6(number, err, arg0, arg1, arg2, arg3, arg4, arg5) \
269({ \
270 long int _sys_result; \
271 \
272 { \
273 register long int __a7 asm ("a7") = number; \
274 register long int __a0 asm ("a0") = (long int) (arg0); \
275 register long int __a1 asm ("a1") = (long int) (arg1); \
276 register long int __a2 asm ("a2") = (long int) (arg2); \
277 register long int __a3 asm ("a3") = (long int) (arg3); \
278 register long int __a4 asm ("a4") = (long int) (arg4); \
279 register long int __a5 asm ("a5") = (long int) (arg5); \
280 __asm__ volatile ( \
281 "scall\n\t" \
282 : "+r" (__a0) \
283 : "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), \
284 "r" (__a4), "r" (__a5) \
285 : __SYSCALL_CLOBBERS); \
286 _sys_result = __a0; \
287 } \
288 _sys_result; \
289})
290
291# define internal_syscall7(number, err, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
292({ \
293 long int _sys_result; \
294 \
295 { \
296 register long int __a7 asm ("a7") = number; \
297 register long int __a0 asm ("a0") = (long int) (arg0); \
298 register long int __a1 asm ("a1") = (long int) (arg1); \
299 register long int __a2 asm ("a2") = (long int) (arg2); \
300 register long int __a3 asm ("a3") = (long int) (arg3); \
301 register long int __a4 asm ("a4") = (long int) (arg4); \
302 register long int __a5 asm ("a5") = (long int) (arg5); \
303 register long int __a6 asm ("a6") = (long int) (arg6); \
304 __asm__ volatile ( \
305 "scall\n\t" \
306 : "+r" (__a0) \
307 : "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), \
308 "r" (__a4), "r" (__a5), "r" (__a6) \
309 : __SYSCALL_CLOBBERS); \
310 _sys_result = __a0; \
311 } \
312 _sys_result; \
313})
314
315# define __SYSCALL_CLOBBERS "memory"
316
317extern long int __syscall_error (long int neg_errno);
318
319#endif /* ! __ASSEMBLER__ */
320
321/* Pointer mangling is not supported. */
322#define PTR_MANGLE(var) (void) (var)
323#define PTR_DEMANGLE(var) (void) (var)
324
325#endif /* linux/riscv/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/s390/asm/unistd.h created+17
...@@ -0,0 +1,17 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * S390 version
4 *
5 * Derived from "include/asm-i386/unistd.h"
6 */
7
8#ifndef _UAPI_ASM_S390_UNISTD_H_
9#define _UAPI_ASM_S390_UNISTD_H_
10
11#ifdef __s390x__
12#include <asm/unistd_64.h>
13#else
14#include <asm/unistd_32.h>
15#endif
16
17#endif /* _UAPI_ASM_S390_UNISTD_H_ */
libc/glibc/sysdeps/unix/sysv/linux/s390/bits/stat.h created+265
...@@ -0,0 +1,265 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <bits/wordsize.h>
26
27#if __WORDSIZE == 64
28/* Versions of the `struct stat' data structure. */
29# define _STAT_VER_KERNEL 0
30# define _STAT_VER_LINUX 1
31# define _STAT_VER _STAT_VER_LINUX
32
33/* Versions of the `xmknod' interface. */
34#define _MKNOD_VER_LINUX 0
35#else
36/* Versions of the `struct stat' data structure. */
37# define _STAT_VER_LINUX_OLD 1
38# define _STAT_VER_KERNEL 1
39# define _STAT_VER_SVR4 2
40# define _STAT_VER_LINUX 3
41# define _STAT_VER _STAT_VER_LINUX
42
43/* Versions of the `xmknod' interface. */
44# define _MKNOD_VER_LINUX 1
45# define _MKNOD_VER_SVR4 2
46# define _MKNOD_VER _MKNOD_VER_LINUX
47#endif
48
49#if __WORDSIZE == 64
50struct stat
51 {
52 __dev_t st_dev; /* Device. */
53 __ino_t st_ino; /* File serial number. */
54 __nlink_t st_nlink; /* Link count. */
55 __mode_t st_mode; /* File mode. */
56 __uid_t st_uid; /* User ID of the file's owner. */
57 __gid_t st_gid; /* Group ID of the file's group.*/
58 int __glibc_reserved0;
59 __dev_t st_rdev; /* Device number, if device. */
60 __off_t st_size; /* Size of file, in bytes. */
61#ifdef __USE_XOPEN2K8
62 /* Nanosecond resolution timestamps are stored in a format
63 equivalent to 'struct timespec'. This is the type used
64 whenever possible but the Unix namespace rules do not allow the
65 identifier 'timespec' to appear in the <sys/stat.h> header.
66 Therefore we have to handle the use of this header in strictly
67 standard-compliant sources special. */
68 struct timespec st_atim; /* Time of last access. */
69 struct timespec st_mtim; /* Time of last modification. */
70 struct timespec st_ctim; /* Time of last status change. */
71# define st_atime st_atim.tv_sec /* Backward compatibility. */
72# define st_mtime st_mtim.tv_sec
73# define st_ctime st_ctim.tv_sec
74#else
75 __time_t st_atime; /* Time of last access. */
76 unsigned long int st_atimensec; /* Nscecs of last access. */
77 __time_t st_mtime; /* Time of last modification. */
78 unsigned long int st_mtimensec; /* Nsecs of last modification. */
79 __time_t st_ctime; /* Time of last status change. */
80 unsigned long int st_ctimensec; /* Nsecs of last status change. */
81#endif
82 __blksize_t st_blksize; /* Optimal block size for I/O. */
83 __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
84 long int __glibc_reserved[3];
85 };
86#else
87struct stat
88 {
89 __dev_t st_dev; /* Device. */
90 unsigned int __pad1;
91# ifndef __USE_FILE_OFFSET64
92 __ino_t st_ino; /* File serial number. */
93# else
94 __ino_t __st_ino; /* 32bit file serial number. */
95# endif
96 __mode_t st_mode; /* File mode. */
97 __nlink_t st_nlink; /* Link count. */
98 __uid_t st_uid; /* User ID of the file's owner. */
99 __gid_t st_gid; /* Group ID of the file's group.*/
100 __dev_t st_rdev; /* Device number, if device. */
101 unsigned int __pad2;
102# ifndef __USE_FILE_OFFSET64
103 __off_t st_size; /* Size of file, in bytes. */
104# else
105 __off64_t st_size; /* Size of file, in bytes. */
106# endif
107 __blksize_t st_blksize; /* Optimal block size for I/O. */
108
109# ifndef __USE_FILE_OFFSET64
110 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
111# else
112 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
113# endif
114# ifdef __USE_XOPEN2K8
115 /* Nanosecond resolution timestamps are stored in a format
116 equivalent to 'struct timespec'. This is the type used
117 whenever possible but the Unix namespace rules do not allow the
118 identifier 'timespec' to appear in the <sys/stat.h> header.
119 Therefore we have to handle the use of this header in strictly
120 standard-compliant sources special. */
121 struct timespec st_atim; /* Time of last access. */
122 struct timespec st_mtim; /* Time of last modification. */
123 struct timespec st_ctim; /* Time of last status change. */
124# define st_atime st_atim.tv_sec /* Backward compatibility. */
125# define st_mtime st_mtim.tv_sec
126# define st_ctime st_ctim.tv_sec
127# else
128 __time_t st_atime; /* Time of last access. */
129 unsigned long int st_atimensec; /* Nscecs of last access. */
130 __time_t st_mtime; /* Time of last modification. */
131 unsigned long int st_mtimensec; /* Nsecs of last modification. */
132 __time_t st_ctime; /* Time of last status change. */
133 unsigned long int st_ctimensec; /* Nsecs of last status change. */
134# endif
135# ifndef __USE_FILE_OFFSET64
136 unsigned long int __glibc_reserved4;
137 unsigned long int __glibc_reserved5;
138# else
139 __ino64_t st_ino; /* File serial number. */
140# endif
141 };
142#endif
143
144#ifdef __USE_LARGEFILE64
145# if __WORDSIZE == 64
146/* Note stat64 is the same shape as stat. */
147struct stat64
148 {
149 __dev_t st_dev; /* Device. */
150 __ino64_t st_ino; /* File serial number. */
151 __nlink_t st_nlink; /* Link count. */
152 __mode_t st_mode; /* File mode. */
153 __uid_t st_uid; /* User ID of the file's owner. */
154 __gid_t st_gid; /* Group ID of the file's group.*/
155 int __glibc_reserved0;
156 __dev_t st_rdev; /* Device number, if device. */
157 __off_t st_size; /* Size of file, in bytes. */
158# ifdef __USE_XOPEN2K8
159 /* Nanosecond resolution timestamps are stored in a format
160 equivalent to 'struct timespec'. This is the type used
161 whenever possible but the Unix namespace rules do not allow the
162 identifier 'timespec' to appear in the <sys/stat.h> header.
163 Therefore we have to handle the use of this header in strictly
164 standard-compliant sources special. */
165 struct timespec st_atim; /* Time of last access. */
166 struct timespec st_mtim; /* Time of last modification. */
167 struct timespec st_ctim; /* Time of last status change. */
168# define st_atime st_atim.tv_sec /* Backward compatibility. */
169# define st_mtime st_mtim.tv_sec
170# define st_ctime st_ctim.tv_sec
171# else
172 __time_t st_atime; /* Time of last access. */
173 unsigned long int st_atimensec; /* Nscecs of last access. */
174 __time_t st_mtime; /* Time of last modification. */
175 unsigned long int st_mtimensec; /* Nsecs of last modification. */
176 __time_t st_ctime; /* Time of last status change. */
177 unsigned long int st_ctimensec; /* Nsecs of last status change. */
178# endif
179 __blksize_t st_blksize; /* Optimal block size for I/O. */
180 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
181 long int __glibc_reserved[3];
182 };
183# else
184struct stat64
185 {
186 __dev_t st_dev; /* Device. */
187 unsigned int __pad1;
188
189 __ino_t __st_ino; /* 32bit file serial number. */
190 __mode_t st_mode; /* File mode. */
191 __nlink_t st_nlink; /* Link count. */
192 __uid_t st_uid; /* User ID of the file's owner. */
193 __gid_t st_gid; /* Group ID of the file's group.*/
194 __dev_t st_rdev; /* Device number, if device. */
195 unsigned int __pad2;
196 __off64_t st_size; /* Size of file, in bytes. */
197 __blksize_t st_blksize; /* Optimal block size for I/O. */
198
199 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
200# ifdef __USE_XOPEN2K8
201 /* Nanosecond resolution timestamps are stored in a format
202 equivalent to 'struct timespec'. This is the type used
203 whenever possible but the Unix namespace rules do not allow the
204 identifier 'timespec' to appear in the <sys/stat.h> header.
205 Therefore we have to handle the use of this header in strictly
206 standard-compliant sources special. */
207 struct timespec st_atim; /* Time of last access. */
208 struct timespec st_mtim; /* Time of last modification. */
209 struct timespec st_ctim; /* Time of last status change. */
210# define st_atime st_atim.tv_sec /* Backward compatibility. */
211# define st_mtime st_mtim.tv_sec
212# define st_ctime st_ctim.tv_sec
213# else
214 __time_t st_atime; /* Time of last access. */
215 unsigned long int st_atimensec; /* Nscecs of last access. */
216 __time_t st_mtime; /* Time of last modification. */
217 unsigned long int st_mtimensec; /* Nsecs of last modification. */
218 __time_t st_ctime; /* Time of last status change. */
219 unsigned long int st_ctimensec; /* Nsecs of last status change. */
220# endif
221 __ino64_t st_ino; /* File serial number. */
222 };
223# endif
224#endif
225
226/* Tell code we have these members. */
227#define _STATBUF_ST_BLKSIZE
228#define _STATBUF_ST_RDEV
229/* Nanosecond resolution time values are supported. */
230#define _STATBUF_ST_NSEC
231
232/* Encoding of the file mode. */
233
234#define __S_IFMT 0170000 /* These bits determine file type. */
235
236/* File types. */
237#define __S_IFDIR 0040000 /* Directory. */
238#define __S_IFCHR 0020000 /* Character device. */
239#define __S_IFBLK 0060000 /* Block device. */
240#define __S_IFREG 0100000 /* Regular file. */
241#define __S_IFIFO 0010000 /* FIFO. */
242#define __S_IFLNK 0120000 /* Symbolic link. */
243#define __S_IFSOCK 0140000 /* Socket. */
244
245/* POSIX.1b objects. Note that these macros always evaluate to zero. But
246 they do it by enforcing the correct use of the macros. */
247#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
248#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
249#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
250
251/* Protection bits. */
252
253#define __S_ISUID 04000 /* Set user ID on execution. */
254#define __S_ISGID 02000 /* Set group ID on execution. */
255#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
256#define __S_IREAD 0400 /* Read by owner. */
257#define __S_IWRITE 0200 /* Write by owner. */
258#define __S_IEXEC 0100 /* Execute by owner. */
259
260#ifdef __USE_ATFILE
261# define UTIME_NOW ((1l << 30) - 1l)
262# define UTIME_OMIT ((1l << 30) - 2l)
263#endif
264
265#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h created+89
...@@ -0,0 +1,89 @@
1/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29#define __DEV_T_TYPE __UQUAD_TYPE
30#define __UID_T_TYPE __U32_TYPE
31#define __GID_T_TYPE __U32_TYPE
32#define __INO_T_TYPE __ULONGWORD_TYPE
33#define __INO64_T_TYPE __UQUAD_TYPE
34#define __MODE_T_TYPE __U32_TYPE
35#define __NLINK_T_TYPE __UWORD_TYPE
36#define __OFF_T_TYPE __SLONGWORD_TYPE
37#define __OFF64_T_TYPE __SQUAD_TYPE
38#define __PID_T_TYPE __S32_TYPE
39#define __RLIM_T_TYPE __ULONGWORD_TYPE
40#define __RLIM64_T_TYPE __UQUAD_TYPE
41#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
42#define __BLKCNT64_T_TYPE __SQUAD_TYPE
43#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
44#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
45#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
46#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
47#define __FSWORD_T_TYPE __SWORD_TYPE
48#define __ID_T_TYPE __U32_TYPE
49#define __CLOCK_T_TYPE __SLONGWORD_TYPE
50#define __TIME_T_TYPE __SLONGWORD_TYPE
51#define __USECONDS_T_TYPE __U32_TYPE
52#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
53#define __DADDR_T_TYPE __S32_TYPE
54#define __KEY_T_TYPE __S32_TYPE
55#define __CLOCKID_T_TYPE __S32_TYPE
56#define __TIMER_T_TYPE void *
57#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
58#define __FSID_T_TYPE struct { int __val[2]; }
59#if defined __GNUC__ && __GNUC__ <= 2
60/* Compatibility with g++ 2.95.x. */
61#define __SSIZE_T_TYPE __SWORD_TYPE
62#else
63/* size_t is unsigned long int on s390 -m31. */
64#define __SSIZE_T_TYPE __SLONGWORD_TYPE
65#endif
66#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
67#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
68#define __CPU_MASK_TYPE __ULONGWORD_TYPE
69
70#ifdef __s390x__
71/* Tell the libc code that off_t and off64_t are actually the same type
72 for all ABI purposes, even if possibly expressed as different base types
73 for C type-checking purposes. */
74# define __OFF_T_MATCHES_OFF64_T 1
75
76/* Same for ino_t and ino64_t. */
77# define __INO_T_MATCHES_INO64_T 1
78
79/* And for __rlim_t and __rlim64_t. */
80# define __RLIM_T_MATCHES_RLIM64_T 1
81#else
82# define __RLIM_T_MATCHES_RLIM64_T 0
83#endif
84
85/* Number of descriptors that can fit in an `fd_set'. */
86#define __FD_SETSIZE 1024
87
88
89#endif /* bits/typesizes.h */
libc/glibc/sysdeps/unix/sysv/linux/s390/kernel-features.h created+52
...@@ -0,0 +1,52 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. S/390 version.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* Direct socketcalls available with kernel 4.3. */
21#if __LINUX_KERNEL_VERSION >= 0x040300
22# define __ASSUME_SOCKET_SYSCALL 1
23# define __ASSUME_SOCKETPAIR_SYSCALL 1
24# define __ASSUME_BIND_SYSCALL 1
25# define __ASSUME_LISTEN_SYSCALL 1
26# define __ASSUME_GETSOCKOPT_SYSCALL 1
27# define __ASSUME_SETSOCKOPT_SYSCALL 1
28# define __ASSUME_GETSOCKNAME_SYSCALL 1
29# define __ASSUME_GETPEERNAME_SYSCALL 1
30# define __ASSUME_SHUTDOWN_SYSCALL 1
31#endif
32
33#include_next <kernel-features.h>
34
35#undef __ASSUME_ACCEPT_SYSCALL
36
37#if __LINUX_KERNEL_VERSION < 0x040300
38# undef __ASSUME_ACCEPT4_SYSCALL
39# undef __ASSUME_RECVMMSG_SYSCALL
40# undef __ASSUME_SENDMMSG_SYSCALL
41# undef __ASSUME_SENDMSG_SYSCALL
42# undef __ASSUME_RECVMSG_SYSCALL
43# undef __ASSUME_CONNECT_SYSCALL
44# undef __ASSUME_RECVFROM_SYSCALL
45# undef __ASSUME_SENDTO_SYSCALL
46#endif
47
48/* s390 only supports ipc syscall. */
49#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
50
51#undef __ASSUME_CLONE_DEFAULT
52#define __ASSUME_CLONE_BACKWARDS2
libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h created+301
...@@ -0,0 +1,301 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_S390_SYSDEP_H
20#define _LINUX_S390_SYSDEP_H
21
22#include <sysdeps/s390/s390-32/sysdep.h>
23#include <sysdeps/unix/sysdep.h>
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
26#include <tls.h>
27
28/* Define __set_errno() for INLINE_SYSCALL macro below. */
29#ifndef __ASSEMBLER__
30#include <errno.h>
31#endif
32
33/* For Linux we can use the system call table in the header file
34 /usr/include/asm/unistd.h
35 of the kernel. But these symbols do not follow the SYS_* syntax
36 so we have to redefine the `SYS_ify' macro here. */
37/* in newer 2.1 kernels __NR_syscall is missing so we define it here */
38#define __NR_syscall 0
39
40#undef SYS_ify
41#define SYS_ify(syscall_name) __NR_##syscall_name
42
43#ifdef __ASSEMBLER__
44
45/* Linux uses a negative return value to indicate syscall errors, unlike
46 most Unices, which use the condition codes' carry flag.
47
48 Since version 2.1 the return value of a system call might be negative
49 even if the call succeeded. E.g., the `lseek' system call might return
50 a large offset. Therefore we must not anymore test for < 0, but test
51 for a real error by making sure the value in gpr2 is a real error
52 number. Linus said he will make sure that no syscall returns a value
53 in -1 .. -4095 as a valid result so we can savely test with -4095. */
54
55#undef PSEUDO
56#define PSEUDO(name, syscall_name, args) \
57 .text; \
58 ENTRY (name) \
59 DO_CALL (syscall_name, args); \
60 lhi %r4,-4095 ; \
61 clr %r2,%r4 ; \
62 jnl SYSCALL_ERROR_LABEL
63
64#undef PSEUDO_END
65#define PSEUDO_END(name) \
66 SYSCALL_ERROR_HANDLER; \
67 END (name)
68
69#undef PSEUDO_NOERRNO
70#define PSEUDO_NOERRNO(name, syscall_name, args) \
71 .text; \
72 ENTRY (name) \
73 DO_CALL (syscall_name, args)
74
75#undef PSEUDO_END_NOERRNO
76#define PSEUDO_END_NOERRNO(name) \
77 END (name)
78
79#undef PSEUDO_ERRVAL
80#define PSEUDO_ERRVAL(name, syscall_name, args) \
81 .text; \
82 ENTRY (name) \
83 DO_CALL (syscall_name, args); \
84 lcr %r2,%r2
85
86#undef PSEUDO_END_ERRVAL
87#define PSEUDO_END_ERRVAL(name) \
88 END (name)
89
90#ifndef PIC
91# define SYSCALL_ERROR_LABEL 0f
92# define SYSCALL_ERROR_HANDLER \
930: basr %r1,0; \
941: l %r1,2f-1b(%r1); \
95 br %r1; \
962: .long syscall_error
97#else
98# if RTLD_PRIVATE_ERRNO
99# define SYSCALL_ERROR_LABEL 0f
100# define SYSCALL_ERROR_HANDLER \
1010: basr %r1,0; \
1021: al %r1,2f-1b(%r1); \
103 lcr %r2,%r2; \
104 st %r2,0(%r1); \
105 lhi %r2,-1; \
106 br %r14; \
1072: .long rtld_errno-1b
108# elif defined _LIBC_REENTRANT
109# if IS_IN (libc)
110# define SYSCALL_ERROR_ERRNO __libc_errno
111# else
112# define SYSCALL_ERROR_ERRNO errno
113# endif
114# define SYSCALL_ERROR_LABEL 0f
115# define SYSCALL_ERROR_HANDLER \
1160: lcr %r0,%r2; \
117 basr %r1,0; \
1181: al %r1,2f-1b(%r1); \
119 l %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1); \
120 ear %r2,%a0; \
121 st %r0,0(%r1,%r2); \
122 lhi %r2,-1; \
123 br %r14; \
1242: .long _GLOBAL_OFFSET_TABLE_-1b
125# else
126# define SYSCALL_ERROR_LABEL 0f
127# define SYSCALL_ERROR_HANDLER \
1280: basr %r1,0; \
1291: al %r1,2f-1b(%r1); \
130 l %r1,errno@GOT(%r1); \
131 lcr %r2,%r2; \
132 st %r2,0(%r1); \
133 lhi %r2,-1; \
134 br %r14; \
1352: .long _GLOBAL_OFFSET_TABLE_-1b
136# endif /* _LIBC_REENTRANT */
137#endif /* PIC */
138
139/* Linux takes system call arguments in registers:
140
141 syscall number 1 call-clobbered
142 arg 1 2 call-clobbered
143 arg 2 3 call-clobbered
144 arg 3 4 call-clobbered
145 arg 4 5 call-clobbered
146 arg 5 6 call-saved
147 arg 6 7 call-saved
148
149 (Of course a function with say 3 arguments does not have entries for
150 arguments 4 and 5.)
151 For system calls with 6 parameters a stack operation is required
152 to load the 6th parameter to register 7. Call saved register 7 is
153 moved to register 0 and back to avoid an additional stack frame.
154 */
155
156#define DO_CALL(syscall, args) \
157 .if args > 5; \
158 lr %r0,%r7; \
159 l %r7,96(%r15); \
160 .endif; \
161 .if SYS_ify (syscall) < 256; \
162 svc SYS_ify (syscall); \
163 .else; \
164 lhi %r1,SYS_ify (syscall); \
165 svc 0; \
166 .endif; \
167 .if args > 5; \
168 lr %r7,%r0; \
169 .endif
170
171#define ret \
172 br 14
173
174#define ret_NOERRNO \
175 br 14
176
177#define ret_ERRVAL \
178 br 14
179
180#endif /* __ASSEMBLER__ */
181
182#undef INLINE_SYSCALL
183#define INLINE_SYSCALL(name, nr, args...) \
184 ({ \
185 unsigned int _ret = INTERNAL_SYSCALL (name, , nr, args); \
186 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \
187 { \
188 __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \
189 _ret = 0xffffffff; \
190 } \
191 (int) _ret; })
192
193#undef INTERNAL_SYSCALL_DECL
194#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
195
196#undef INTERNAL_SYSCALL_DIRECT
197#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...) \
198 ({ \
199 DECLARGS_##nr(args) \
200 register int _ret __asm__("2"); \
201 __asm__ __volatile__ ( \
202 "svc %b1\n\t" \
203 : "=d" (_ret) \
204 : "i" (__NR_##name) ASMFMT_##nr \
205 : "memory" ); \
206 _ret; })
207
208#undef INTERNAL_SYSCALL_SVC0
209#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...) \
210 ({ \
211 DECLARGS_##nr(args) \
212 register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name); \
213 register int _ret __asm__("2"); \
214 __asm__ __volatile__ ( \
215 "svc 0\n\t" \
216 : "=d" (_ret) \
217 : "d" (_nr) ASMFMT_##nr \
218 : "memory" ); \
219 _ret; })
220
221#undef INTERNAL_SYSCALL_NCS
222#define INTERNAL_SYSCALL_NCS(no, err, nr, args...) \
223 ({ \
224 DECLARGS_##nr(args) \
225 register unsigned long _nr __asm__("1") = (unsigned long)(no); \
226 register int _ret __asm__("2"); \
227 __asm__ __volatile__ ( \
228 "svc 0\n\t" \
229 : "=d" (_ret) \
230 : "d" (_nr) ASMFMT_##nr \
231 : "memory" ); \
232 _ret; })
233
234#undef INTERNAL_SYSCALL
235#define INTERNAL_SYSCALL(name, err, nr, args...) \
236 (((__NR_##name) < 256) ? \
237 INTERNAL_SYSCALL_DIRECT(name, err, nr, args) : \
238 INTERNAL_SYSCALL_SVC0(name, err,nr, args))
239
240#undef INTERNAL_SYSCALL_ERROR_P
241#define INTERNAL_SYSCALL_ERROR_P(val, err) \
242 ((unsigned int) (val) >= 0xfffff001u)
243
244#undef INTERNAL_SYSCALL_ERRNO
245#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
246
247#define DECLARGS_0()
248#define DECLARGS_1(arg1) \
249 register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
250#define DECLARGS_2(arg1, arg2) \
251 DECLARGS_1(arg1) \
252 register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
253#define DECLARGS_3(arg1, arg2, arg3) \
254 DECLARGS_2(arg1, arg2) \
255 register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
256#define DECLARGS_4(arg1, arg2, arg3, arg4) \
257 DECLARGS_3(arg1, arg2, arg3) \
258 register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
259#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
260 DECLARGS_4(arg1, arg2, arg3, arg4) \
261 register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
262#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
263 DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
264 register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
265
266#define ASMFMT_0
267#define ASMFMT_1 , "0" (gpr2)
268#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
269#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
270#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
271#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
272#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
273
274/* List of system calls which are supported as vsyscalls. */
275#define HAVE_CLOCK_GETRES_VSYSCALL 1
276#define HAVE_CLOCK_GETTIME_VSYSCALL 1
277#define HAVE_GETTIMEOFDAY_VSYSCALL 1
278#define HAVE_GETCPU_VSYSCALL 1
279
280/* Pointer mangling support. */
281#if IS_IN (rtld)
282/* We cannot use the thread descriptor because in ld.so we use setjmp
283 earlier than the descriptor is initialized. */
284#else
285/* For the time being just use stack_guard rather than a separate
286 pointer_guard. */
287# ifdef __ASSEMBLER__
288# define PTR_MANGLE(reg, tmpreg) \
289 ear tmpreg,%a0; \
290 x reg,STACK_GUARD(tmpreg)
291# define PTR_MANGLE2(reg, tmpreg) \
292 x reg,STACK_GUARD(tmpreg)
293# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
294# else
295# define PTR_MANGLE(var) \
296 (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
297# define PTR_DEMANGLE(var) PTR_MANGLE (var)
298# endif
299#endif
300
301#endif /* _LINUX_S390_SYSDEP_H */
libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h created+311
...@@ -0,0 +1,311 @@
1/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LINUX_S390_SYSDEP_H
21#define _LINUX_S390_SYSDEP_H
22
23#include <sysdeps/s390/s390-64/sysdep.h>
24#include <sysdeps/unix/sysdep.h>
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
27#include <tls.h>
28
29/* Define __set_errno() for INLINE_SYSCALL macro below. */
30#ifndef __ASSEMBLER__
31#include <errno.h>
32#endif
33
34/* For Linux we can use the system call table in the header file
35 /usr/include/asm/unistd.h
36 of the kernel. But these symbols do not follow the SYS_* syntax
37 so we have to redefine the `SYS_ify' macro here. */
38/* In newer 2.1 kernels __NR_syscall is missing so we define it here. */
39#define __NR_syscall 0
40
41/*
42 * Newer kernel versions redefined __NR_pread and __NR_pwrite to
43 * __NR_pread64 and __NR_pwrite64.
44 */
45#ifndef __NR_pread
46# define __NR_pread __NR_pread64
47#endif
48#ifndef __NR_pwrite
49# define __NR_pwrite __NR_pwrite64
50#endif
51
52#undef SYS_ify
53#define SYS_ify(syscall_name) __NR_##syscall_name
54
55#ifdef __ASSEMBLER__
56
57/* Linux uses a negative return value to indicate syscall errors, unlike
58 most Unices, which use the condition codes' carry flag.
59
60 Since version 2.1 the return value of a system call might be negative
61 even if the call succeeded. E.g., the `lseek' system call might return
62 a large offset. Therefore we must not anymore test for < 0, but test
63 for a real error by making sure the value in gpr2 is a real error
64 number. Linus said he will make sure that no syscall returns a value
65 in -1 .. -4095 as a valid result so we can savely test with -4095. */
66
67#undef PSEUDO
68#define PSEUDO(name, syscall_name, args) \
69 .text; \
70 ENTRY (name) \
71 DO_CALL (syscall_name, args); \
72 lghi %r4,-4095 ; \
73 clgr %r2,%r4 ; \
74 jgnl SYSCALL_ERROR_LABEL
75
76#undef PSEUDO_END
77#define PSEUDO_END(name) \
78 SYSCALL_ERROR_HANDLER; \
79 END (name)
80
81#undef PSEUDO_NOERRNO
82#define PSEUDO_NOERRNO(name, syscall_name, args) \
83 .text; \
84 ENTRY (name) \
85 DO_CALL (syscall_name, args)
86
87#undef PSEUDO_END_NOERRNO
88#define PSEUDO_END_NOERRNO(name) \
89 SYSCALL_ERROR_HANDLER; \
90 END (name)
91
92#undef PSEUDO_ERRVAL
93#define PSEUDO_ERRVAL(name, syscall_name, args) \
94 .text; \
95 ENTRY (name) \
96 DO_CALL (syscall_name, args); \
97 lcgr %r2,%r2
98
99#undef PSEUDO_END_ERRVAL
100#define PSEUDO_END_ERRVAL(name) \
101 SYSCALL_ERROR_HANDLER; \
102 END (name)
103
104#ifndef PIC
105# define SYSCALL_ERROR_LABEL syscall_error
106# define SYSCALL_ERROR_HANDLER
107#else
108# if RTLD_PRIVATE_ERRNO
109# define SYSCALL_ERROR_LABEL 0f
110# define SYSCALL_ERROR_HANDLER \
1110: larl %r1,rtld_errno; \
112 lcr %r2,%r2; \
113 st %r2,0(%r1); \
114 lghi %r2,-1; \
115 br %r14
116# elif defined _LIBC_REENTRANT
117# if IS_IN (libc)
118# define SYSCALL_ERROR_ERRNO __libc_errno
119# else
120# define SYSCALL_ERROR_ERRNO errno
121# endif
122# define SYSCALL_ERROR_LABEL 0f
123# define SYSCALL_ERROR_HANDLER \
1240: lcr %r0,%r2; \
125 larl %r1,SYSCALL_ERROR_ERRNO@indntpoff; \
126 lg %r1,0(%r1); \
127 ear %r2,%a0; \
128 sllg %r2,%r2,32; \
129 ear %r2,%a1; \
130 st %r0,0(%r1,%r2); \
131 lghi %r2,-1; \
132 br %r14
133# else
134# define SYSCALL_ERROR_LABEL 0f
135# define SYSCALL_ERROR_HANDLER \
1360: larl %r1,_GLOBAL_OFFSET_TABLE_; \
137 lg %r1,errno@GOT(%r1); \
138 lcr %r2,%r2; \
139 st %r2,0(%r1); \
140 lghi %r2,-1; \
141 br %r14
142# endif /* _LIBC_REENTRANT */
143#endif /* PIC */
144
145/* Linux takes system call arguments in registers:
146
147 syscall number 1 call-clobbered
148 arg 1 2 call-clobbered
149 arg 2 3 call-clobbered
150 arg 3 4 call-clobbered
151 arg 4 5 call-clobbered
152 arg 5 6 call-saved
153 arg 6 7 call-saved
154
155 (Of course a function with say 3 arguments does not have entries for
156 arguments 4 and 5.)
157 For system calls with 6 parameters a stack operation is required
158 to load the 6th parameter to register 7. Call saved register 7 is
159 moved to register 0 and back to avoid an additional stack frame.
160 */
161
162#define DO_CALL(syscall, args) \
163 .if args > 5; \
164 lgr %r0,%r7; \
165 lg %r7,160(%r15); \
166 .endif; \
167 .if SYS_ify (syscall) < 256; \
168 svc SYS_ify (syscall); \
169 .else; \
170 lghi %r1,SYS_ify (syscall); \
171 svc 0; \
172 .endif; \
173 .if args > 5; \
174 lgr %r7,%r0; \
175 .endif
176
177#define ret \
178 br 14
179
180#define ret_NOERRNO \
181 br 14
182
183#define ret_ERRVAL \
184 br 14
185
186#endif /* __ASSEMBLER__ */
187
188#undef INLINE_SYSCALL
189#define INLINE_SYSCALL(name, nr, args...) \
190 ({ \
191 long _ret = INTERNAL_SYSCALL (name, , nr, args); \
192 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \
193 { \
194 __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \
195 _ret = -1; \
196 } \
197 _ret; })
198
199#undef INTERNAL_SYSCALL_DECL
200#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
201
202#undef INTERNAL_SYSCALL_DIRECT
203#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...) \
204 ({ \
205 DECLARGS_##nr(args) \
206 register long _ret __asm__("2"); \
207 __asm__ __volatile__ ( \
208 "svc %b1\n\t" \
209 : "=d" (_ret) \
210 : "i" (__NR_##name) ASMFMT_##nr \
211 : "memory" ); \
212 _ret; })
213
214#undef INTERNAL_SYSCALL_SVC0
215#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...) \
216 ({ \
217 DECLARGS_##nr(args) \
218 register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name); \
219 register long _ret __asm__("2"); \
220 __asm__ __volatile__ ( \
221 "svc 0\n\t" \
222 : "=d" (_ret) \
223 : "d" (_nr) ASMFMT_##nr \
224 : "memory" ); \
225 _ret; })
226
227#undef INTERNAL_SYSCALL_NCS
228#define INTERNAL_SYSCALL_NCS(no, err, nr, args...) \
229 ({ \
230 DECLARGS_##nr(args) \
231 register unsigned long _nr __asm__("1") = (unsigned long)(no); \
232 register long _ret __asm__("2"); \
233 __asm__ __volatile__ ( \
234 "svc 0\n\t" \
235 : "=d" (_ret) \
236 : "d" (_nr) ASMFMT_##nr \
237 : "memory" ); \
238 _ret; })
239
240#undef INTERNAL_SYSCALL
241#define INTERNAL_SYSCALL(name, err, nr, args...) \
242 (((__NR_##name) < 256) ? \
243 INTERNAL_SYSCALL_DIRECT(name, err, nr, args) : \
244 INTERNAL_SYSCALL_SVC0(name, err,nr, args))
245
246#undef INTERNAL_SYSCALL_ERROR_P
247#define INTERNAL_SYSCALL_ERROR_P(val, err) \
248 ((unsigned long) (val) >= -4095UL)
249
250#undef INTERNAL_SYSCALL_ERRNO
251#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
252
253#define DECLARGS_0()
254#define DECLARGS_1(arg1) \
255 register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
256#define DECLARGS_2(arg1, arg2) \
257 DECLARGS_1(arg1) \
258 register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
259#define DECLARGS_3(arg1, arg2, arg3) \
260 DECLARGS_2(arg1, arg2) \
261 register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
262#define DECLARGS_4(arg1, arg2, arg3, arg4) \
263 DECLARGS_3(arg1, arg2, arg3) \
264 register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
265#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
266 DECLARGS_4(arg1, arg2, arg3, arg4) \
267 register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
268#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
269 DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
270 register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
271
272#define ASMFMT_0
273#define ASMFMT_1 , "0" (gpr2)
274#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
275#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
276#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
277#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
278#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
279
280/* List of system calls which are supported as vsyscalls. */
281#define HAVE_CLOCK_GETRES_VSYSCALL 1
282#define HAVE_CLOCK_GETTIME_VSYSCALL 1
283#define HAVE_GETTIMEOFDAY_VSYSCALL 1
284#define HAVE_GETCPU_VSYSCALL 1
285
286#define SINGLE_THREAD_BY_GLOBAL 1
287
288/* Pointer mangling support. */
289#if IS_IN (rtld)
290/* We cannot use the thread descriptor because in ld.so we use setjmp
291 earlier than the descriptor is initialized. */
292#else
293/* For the time being just use stack_guard rather than a separate
294 pointer_guard. */
295# ifdef __ASSEMBLER__
296# define PTR_MANGLE(reg, tmpreg) \
297 ear tmpreg,%a0; \
298 sllg tmpreg,tmpreg,32; \
299 ear tmpreg,%a1; \
300 xg reg,STACK_GUARD(tmpreg)
301# define PTR_MANGLE2(reg, tmpreg) \
302 xg reg,STACK_GUARD(tmpreg)
303# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
304# else
305# define PTR_MANGLE(var) \
306 (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
307# define PTR_DEMANGLE(var) PTR_MANGLE (var)
308# endif
309#endif
310
311#endif /* _LINUX_S390_SYSDEP_H */
libc/glibc/sysdeps/unix/sysv/linux/s390/sys/elf.h created+25
...@@ -0,0 +1,25 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_ELF_H
19#define _SYS_ELF_H 1
20
21#warning "This header is obsolete; use <sys/procfs.h> instead."
22
23#include <sys/procfs.h>
24
25#endif /* _SYS_ELF_H */
libc/glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h created+58
...@@ -0,0 +1,58 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. SH version.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef __KERNEL_FEATURES_SH__
21# define __KERNEL_FEATURES_SH__
22
23/* These syscalls were added for SH in 2.6.37. */
24#define __ASSUME_SOCKET_SYSCALL 1
25#define __ASSUME_BIND_SYSCALL 1
26#define __ASSUME_CONNECT_SYSCALL 1
27#define __ASSUME_LISTEN_SYSCALL 1
28#define __ASSUME_GETSOCKNAME_SYSCALL 1
29#define __ASSUME_GETPEERNAME_SYSCALL 1
30#define __ASSUME_SOCKETPAIR_SYSCALL 1
31#define __ASSUME_SEND_SYSCALL 1
32#define __ASSUME_RECV_SYSCALL 1
33#define __ASSUME_SHUTDOWN_SYSCALL 1
34#define __ASSUME_GETSOCKOPT_SYSCALL 1
35#define __ASSUME_SETSOCKOPT_SYSCALL 1
36
37#include_next <kernel-features.h>
38
39/* SH4 ABI does not really require argument alignment for 64-bits, but
40 the kernel interface for p{read,write}64 adds a dummy long argument
41 before the offset. */
42#define __ASSUME_PRW_DUMMY_ARG 1
43
44/* sh only supports ipc syscall. */
45#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
46
47/* Support for several syscalls was added in 4.8. */
48#if __LINUX_KERNEL_VERSION < 0x040800
49# undef __ASSUME_RENAMEAT2
50# undef __ASSUME_EXECVEAT
51# undef __ASSUME_MLOCK2
52# undef __ASSUME_COPY_FILE_RANGE
53#endif
54
55/* sh does not support the statx system call. */
56#undef __ASSUME_STATX
57
58#endif
libc/glibc/sysdeps/unix/sysv/linux/sh/sh4/sysdep.h created+4
...@@ -0,0 +1,4 @@
1/* 4 instruction cycles not accessing cache and TLB are needed after
2 trapa instruction to avoid an SH-4 silicon bug. */
3#define NEED_SYSCALL_INST_PAD
4#include <sysdeps/unix/sysv/linux/sh/sysdep.h>
libc/glibc/sysdeps/unix/sysv/linux/sh/sysdep.h created+360
...@@ -0,0 +1,360 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
4 Changed by Kaz Kojima, <kkojima@rr.iij4u.or.jp>.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LINUX_SH_SYSDEP_H
21#define _LINUX_SH_SYSDEP_H 1
22
23/* There is some commonality. */
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <sysdeps/unix/sh/sysdep.h>
26#include <tls.h>
27
28/* For Linux we can use the system call table in the header file
29 /usr/include/asm/unistd.h
30 of the kernel. But these symbols do not follow the SYS_* syntax
31 so we have to redefine the `SYS_ify' macro here. */
32#undef SYS_ify
33#define SYS_ify(syscall_name) (__NR_##syscall_name)
34
35
36#ifdef __ASSEMBLER__
37
38/* Linux uses a negative return value to indicate syscall errors,
39 unlike most Unices, which use the condition codes' carry flag.
40
41 Since version 2.1 the return value of a system call might be
42 negative even if the call succeeded. E.g., the `lseek' system call
43 might return a large offset. Therefore we must not anymore test
44 for < 0, but test for a real error by making sure the value in R0
45 is a real error number. Linus said he will make sure the no syscall
46 returns a value in -1 .. -4095 as a valid result so we can savely
47 test with -4095. */
48
49#define _IMM1 #-1
50#define _IMM12 #-12
51#undef PSEUDO
52#define PSEUDO(name, syscall_name, args) \
53 .text; \
54 ENTRY (name); \
55 DO_CALL (syscall_name, args); \
56 mov r0,r1; \
57 mov _IMM12,r2; \
58 shad r2,r1; \
59 not r1,r1; \
60 tst r1,r1; \
61 bf .Lpseudo_end; \
62 SYSCALL_ERROR_HANDLER; \
63 .Lpseudo_end:
64
65#undef PSEUDO_END
66#define PSEUDO_END(name) \
67 END (name)
68
69#undef PSEUDO_NOERRNO
70#define PSEUDO_NOERRNO(name, syscall_name, args) \
71 .text; \
72 ENTRY (name); \
73 DO_CALL (syscall_name, args)
74
75#undef PSEUDO_END_NOERRNO
76#define PSEUDO_END_NOERRNO(name) \
77 END (name)
78
79#define ret_NOERRNO ret
80
81#define PSEUDO_ERRVAL(name, syscall_name, args) \
82 .text; \
83 ENTRY (name); \
84 DO_CALL (syscall_name, args);
85
86#undef PSEUDO_END_ERRVAL
87#define PSEUDO_END_ERRVAL(name) \
88 END (name)
89
90#define ret_ERRVAL ret
91
92#ifndef PIC
93# define SYSCALL_ERROR_HANDLER \
94 mov.l 0f,r1; \
95 jmp @r1; \
96 mov r0,r4; \
97 .align 2; \
98 0: .long __syscall_error
99#else
100# if RTLD_PRIVATE_ERRNO
101# define SYSCALL_ERROR_HANDLER \
102 neg r0,r1; \
103 mov r12,r2; \
104 cfi_register (r12, r2); \
105 mov.l 0f,r12; \
106 mova 0f,r0; \
107 add r0,r12; \
108 mov.l 1f,r0; \
109 mov.l r1,@(r0,r12); \
110 mov r2,r12; \
111 cfi_restore (r12); \
112 bra .Lpseudo_end; \
113 mov _IMM1,r0; \
114 .align 2; \
115 0: .long _GLOBAL_OFFSET_TABLE_; \
116 1: .long rtld_errno@GOTOFF
117
118# elif defined _LIBC_REENTRANT
119
120# if IS_IN (libc)
121# define SYSCALL_ERROR_ERRNO __libc_errno
122# else
123# define SYSCALL_ERROR_ERRNO errno
124# endif
125# define SYSCALL_ERROR_HANDLER \
126 neg r0,r1; \
127 mov r12,r2; \
128 cfi_register (r12, r2); \
129 mov.l 0f,r12; \
130 mova 0f,r0; \
131 add r0,r12; \
132 mov.l 1f,r0; \
133 stc gbr, r4; \
134 mov.l @(r0,r12),r0; \
135 mov r2,r12; \
136 cfi_restore (r12); \
137 add r4,r0; \
138 mov.l r1,@r0; \
139 bra .Lpseudo_end; \
140 mov _IMM1,r0; \
141 .align 2; \
142 0: .long _GLOBAL_OFFSET_TABLE_; \
143 1: .long SYSCALL_ERROR_ERRNO@GOTTPOFF
144# else
145/* Store (-r0) into errno through the GOT. */
146# define SYSCALL_ERROR_HANDLER \
147 neg r0,r1; \
148 mov r12,r2; \
149 cfi_register (r12, r2); \
150 mov.l 0f,r12; \
151 mova 0f,r0; \
152 add r0,r12; \
153 mov.l 1f,r0; \
154 mov.l @(r0,r12),r0; \
155 mov r2,r12; \
156 cfi_restore (r12); \
157 mov.l r1,@r0; \
158 bra .Lpseudo_end; \
159 mov _IMM1,r0; \
160 .align 2; \
161 0: .long _GLOBAL_OFFSET_TABLE_; \
162 1: .long errno@GOT
163# endif /* _LIBC_REENTRANT */
164#endif /* PIC */
165
166# ifdef NEED_SYSCALL_INST_PAD
167# define SYSCALL_INST_PAD \
168 or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0
169# else
170# define SYSCALL_INST_PAD
171# endif
172
173#define SYSCALL_INST0 trapa #0x10
174#define SYSCALL_INST1 trapa #0x11
175#define SYSCALL_INST2 trapa #0x12
176#define SYSCALL_INST3 trapa #0x13
177#define SYSCALL_INST4 trapa #0x14
178#define SYSCALL_INST5 mov.l @(0,r15),r0; trapa #0x15
179#define SYSCALL_INST6 mov.l @(0,r15),r0; mov.l @(4,r15),r1; trapa #0x16
180
181#undef DO_CALL
182#define DO_CALL(syscall_name, args) \
183 mov.l 1f,r3; \
184 SYSCALL_INST##args; \
185 SYSCALL_INST_PAD; \
186 bra 2f; \
187 nop; \
188 .align 2; \
189 1: .long SYS_ify (syscall_name); \
190 2:
191
192#else /* not __ASSEMBLER__ */
193
194#define SYSCALL_INST_STR0 "trapa #0x10\n\t"
195#define SYSCALL_INST_STR1 "trapa #0x11\n\t"
196#define SYSCALL_INST_STR2 "trapa #0x12\n\t"
197#define SYSCALL_INST_STR3 "trapa #0x13\n\t"
198#define SYSCALL_INST_STR4 "trapa #0x14\n\t"
199#define SYSCALL_INST_STR5 "trapa #0x15\n\t"
200#define SYSCALL_INST_STR6 "trapa #0x16\n\t"
201
202# ifdef NEED_SYSCALL_INST_PAD
203# define SYSCALL_INST_PAD "\
204 or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0"
205# else
206# define SYSCALL_INST_PAD
207# endif
208
209#define ASMFMT_0
210#define ASMFMT_1 \
211 , "r" (r4)
212#define ASMFMT_2 \
213 , "r" (r4), "r" (r5)
214#define ASMFMT_3 \
215 , "r" (r4), "r" (r5), "r" (r6)
216#define ASMFMT_4 \
217 , "r" (r4), "r" (r5), "r" (r6), "r" (r7)
218#define ASMFMT_5 \
219 , "r" (r4), "r" (r5), "r" (r6), "r" (r7), "0" (r0)
220#define ASMFMT_6 \
221 , "r" (r4), "r" (r5), "r" (r6), "r" (r7), "0" (r0), "r" (r1)
222#define ASMFMT_7 \
223 , "r" (r4), "r" (r5), "r" (r6), "r" (r7), "0" (r0), "r" (r1), "r" (r2)
224
225#define SUBSTITUTE_ARGS_0()
226#define SUBSTITUTE_ARGS_1(arg1) \
227 long int _arg1 = (long int) (arg1); \
228 register long int r4 asm ("%r4") = (long int) (_arg1)
229#define SUBSTITUTE_ARGS_2(arg1, arg2) \
230 long int _arg1 = (long int) (arg1); \
231 long int _arg2 = (long int) (arg2); \
232 register long int r4 asm ("%r4") = (long int) (_arg1); \
233 register long int r5 asm ("%r5") = (long int) (_arg2)
234#define SUBSTITUTE_ARGS_3(arg1, arg2, arg3) \
235 long int _arg1 = (long int) (arg1); \
236 long int _arg2 = (long int) (arg2); \
237 long int _arg3 = (long int) (arg3); \
238 register long int r4 asm ("%r4") = (long int) (_arg1); \
239 register long int r5 asm ("%r5") = (long int) (_arg2); \
240 register long int r6 asm ("%r6") = (long int) (_arg3)
241#define SUBSTITUTE_ARGS_4(arg1, arg2, arg3, arg4) \
242 long int _arg1 = (long int) (arg1); \
243 long int _arg2 = (long int) (arg2); \
244 long int _arg3 = (long int) (arg3); \
245 long int _arg4 = (long int) (arg4); \
246 register long int r4 asm ("%r4") = (long int) (_arg1); \
247 register long int r5 asm ("%r5") = (long int) (_arg2); \
248 register long int r6 asm ("%r6") = (long int) (_arg3); \
249 register long int r7 asm ("%r7") = (long int) (_arg4)
250#define SUBSTITUTE_ARGS_5(arg1, arg2, arg3, arg4, arg5) \
251 long int _arg1 = (long int) (arg1); \
252 long int _arg2 = (long int) (arg2); \
253 long int _arg3 = (long int) (arg3); \
254 long int _arg4 = (long int) (arg4); \
255 long int _arg5 = (long int) (arg5); \
256 register long int r4 asm ("%r4") = (long int) (_arg1); \
257 register long int r5 asm ("%r5") = (long int) (_arg2); \
258 register long int r6 asm ("%r6") = (long int) (_arg3); \
259 register long int r7 asm ("%r7") = (long int) (_arg4); \
260 register long int r0 asm ("%r0") = (long int) (_arg5)
261#define SUBSTITUTE_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
262 long int _arg1 = (long int) (arg1); \
263 long int _arg2 = (long int) (arg2); \
264 long int _arg3 = (long int) (arg3); \
265 long int _arg4 = (long int) (arg4); \
266 long int _arg5 = (long int) (arg5); \
267 long int _arg6 = (long int) (arg6); \
268 register long int r4 asm ("%r4") = (long int)(_arg1); \
269 register long int r5 asm ("%r5") = (long int) (_arg2); \
270 register long int r6 asm ("%r6") = (long int) (_arg3); \
271 register long int r7 asm ("%r7") = (long int) (_arg4); \
272 register long int r0 asm ("%r0") = (long int) (_arg5); \
273 register long int r1 asm ("%r1") = (long int) (_arg6)
274#define SUBSTITUTE_ARGS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
275 long int _arg1 = (long int) (arg1); \
276 long int _arg2 = (long int) (arg2); \
277 long int _arg3 = (long int) (arg3); \
278 long int _arg4 = (long int) (arg4); \
279 long int _arg5 = (long int) (arg5); \
280 long int _arg6 = (long int) (arg6); \
281 long int _arg7 = (long int) (arg7); \
282 register long int r4 asm ("%r4") = (long int) (_arg1); \
283 register long int r5 asm ("%r5") = (long int) (_arg2); \
284 register long int r6 asm ("%r6") = (long int) (_arg3); \
285 register long int r7 asm ("%r7") = (long int) (_arg4); \
286 register long int r0 asm ("%r0") = (long int) (_arg5); \
287 register long int r1 asm ("%r1") = (long int) (_arg6); \
288 register long int r2 asm ("%r2") = (long int) (_arg7)
289
290#undef INLINE_SYSCALL
291#define INLINE_SYSCALL(name, nr, args...) \
292 ({ \
293 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
294 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
295 { \
296 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
297 resultvar = 0xffffffff; \
298 } \
299 (int) resultvar; })
300
301#undef INTERNAL_SYSCALL
302#define INTERNAL_SYSCALL(name, err, nr, args...) \
303 ({ \
304 unsigned long int resultvar; \
305 register long int r3 asm ("%r3") = SYS_ify (name); \
306 SUBSTITUTE_ARGS_##nr(args); \
307 \
308 asm volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
309 : "=z" (resultvar) \
310 : "r" (r3) ASMFMT_##nr \
311 : "memory", "t"); \
312 \
313 (int) resultvar; })
314
315/* The _NCS variant allows non-constant syscall numbers. */
316#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
317 ({ \
318 unsigned long int resultvar; \
319 register long int r3 asm ("%r3") = (name); \
320 SUBSTITUTE_ARGS_##nr(args); \
321 \
322 asm volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
323 : "=z" (resultvar) \
324 : "r" (r3) ASMFMT_##nr \
325 : "memory", "t"); \
326 \
327 (int) resultvar; })
328
329#undef INTERNAL_SYSCALL_DECL
330#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
331
332#undef INTERNAL_SYSCALL_ERROR_P
333#define INTERNAL_SYSCALL_ERROR_P(val, err) \
334 ((unsigned int) (val) >= 0xfffff001u)
335
336#undef INTERNAL_SYSCALL_ERRNO
337#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
338
339#endif /* __ASSEMBLER__ */
340
341/* Pointer mangling support. */
342#if IS_IN (rtld)
343/* We cannot use the thread descriptor because in ld.so we use setjmp
344 earlier than the descriptor is initialized. Using a global variable
345 is too complicated here since we have no PC-relative addressing mode. */
346#else
347# ifdef __ASSEMBLER__
348# define PTR_MANGLE(reg, tmp) \
349 stc gbr,tmp; mov.l @(POINTER_GUARD,tmp),tmp; xor tmp,reg
350# define PTR_MANGLE2(reg, tmp) xor tmp,reg
351# define PTR_DEMANGLE(reg, tmp) PTR_MANGLE (reg, tmp)
352# define PTR_DEMANGLE2(reg, tmp) PTR_MANGLE2 (reg, tmp)
353# else
354# define PTR_MANGLE(var) \
355 (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
356# define PTR_DEMANGLE(var) PTR_MANGLE (var)
357# endif
358#endif
359
360#endif /* linux/sh/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/sparc/asm/unistd.h created+453
...@@ -0,0 +1,453 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * System calls under the Sparc.
4 *
5 * Don't be scared by the ugly clobbers, it is the only way I can
6 * think of right now to force the arguments into fixed registers
7 * before the trap into the system call with gcc 'asm' statements.
8 *
9 * Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
10 *
11 * SunOS compatibility based upon preliminary work which is:
12 *
13 * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu)
14 */
15#ifndef _UAPI_SPARC_UNISTD_H
16#define _UAPI_SPARC_UNISTD_H
17
18#ifndef __32bit_syscall_numbers__
19#ifndef __arch64__
20#define __32bit_syscall_numbers__
21#endif
22#endif
23
24#define __NR_restart_syscall 0 /* Linux Specific */
25#define __NR_exit 1 /* Common */
26#define __NR_fork 2 /* Common */
27#define __NR_read 3 /* Common */
28#define __NR_write 4 /* Common */
29#define __NR_open 5 /* Common */
30#define __NR_close 6 /* Common */
31#define __NR_wait4 7 /* Common */
32#define __NR_creat 8 /* Common */
33#define __NR_link 9 /* Common */
34#define __NR_unlink 10 /* Common */
35#define __NR_execv 11 /* SunOS Specific */
36#define __NR_chdir 12 /* Common */
37#define __NR_chown 13 /* Common */
38#define __NR_mknod 14 /* Common */
39#define __NR_chmod 15 /* Common */
40#define __NR_lchown 16 /* Common */
41#define __NR_brk 17 /* Common */
42#define __NR_perfctr 18 /* Performance counter operations */
43#define __NR_lseek 19 /* Common */
44#define __NR_getpid 20 /* Common */
45#define __NR_capget 21 /* Linux Specific */
46#define __NR_capset 22 /* Linux Specific */
47#define __NR_setuid 23 /* Implemented via setreuid in SunOS */
48#define __NR_getuid 24 /* Common */
49#define __NR_vmsplice 25 /* ENOSYS under SunOS */
50#define __NR_ptrace 26 /* Common */
51#define __NR_alarm 27 /* Implemented via setitimer in SunOS */
52#define __NR_sigaltstack 28 /* Common */
53#define __NR_pause 29 /* Is sigblock(0)->sigpause() in SunOS */
54#define __NR_utime 30 /* Implemented via utimes() under SunOS */
55#ifdef __32bit_syscall_numbers__
56#define __NR_lchown32 31 /* Linux sparc32 specific */
57#define __NR_fchown32 32 /* Linux sparc32 specific */
58#endif
59#define __NR_access 33 /* Common */
60#define __NR_nice 34 /* Implemented via get/setpriority() in SunOS */
61#ifdef __32bit_syscall_numbers__
62#define __NR_chown32 35 /* Linux sparc32 specific */
63#endif
64#define __NR_sync 36 /* Common */
65#define __NR_kill 37 /* Common */
66#define __NR_stat 38 /* Common */
67#define __NR_sendfile 39 /* Linux Specific */
68#define __NR_lstat 40 /* Common */
69#define __NR_dup 41 /* Common */
70#define __NR_pipe 42 /* Common */
71#define __NR_times 43 /* Implemented via getrusage() in SunOS */
72#ifdef __32bit_syscall_numbers__
73#define __NR_getuid32 44 /* Linux sparc32 specific */
74#endif
75#define __NR_umount2 45 /* Linux Specific */
76#define __NR_setgid 46 /* Implemented via setregid() in SunOS */
77#define __NR_getgid 47 /* Common */
78#define __NR_signal 48 /* Implemented via sigvec() in SunOS */
79#define __NR_geteuid 49 /* SunOS calls getuid() */
80#define __NR_getegid 50 /* SunOS calls getgid() */
81#define __NR_acct 51 /* Common */
82#ifdef __32bit_syscall_numbers__
83#define __NR_getgid32 53 /* Linux sparc32 specific */
84#else
85#define __NR_memory_ordering 52 /* Linux Specific */
86#endif
87#define __NR_ioctl 54 /* Common */
88#define __NR_reboot 55 /* Common */
89#ifdef __32bit_syscall_numbers__
90#define __NR_mmap2 56 /* Linux sparc32 Specific */
91#endif
92#define __NR_symlink 57 /* Common */
93#define __NR_readlink 58 /* Common */
94#define __NR_execve 59 /* Common */
95#define __NR_umask 60 /* Common */
96#define __NR_chroot 61 /* Common */
97#define __NR_fstat 62 /* Common */
98#define __NR_fstat64 63 /* Linux Specific */
99#define __NR_getpagesize 64 /* Common */
100#define __NR_msync 65 /* Common in newer 1.3.x revs... */
101#define __NR_vfork 66 /* Common */
102#define __NR_pread64 67 /* Linux Specific */
103#define __NR_pwrite64 68 /* Linux Specific */
104#ifdef __32bit_syscall_numbers__
105#define __NR_geteuid32 69 /* Linux sparc32, sbrk under SunOS */
106#define __NR_getegid32 70 /* Linux sparc32, sstk under SunOS */
107#endif
108#define __NR_mmap 71 /* Common */
109#ifdef __32bit_syscall_numbers__
110#define __NR_setreuid32 72 /* Linux sparc32, vadvise under SunOS */
111#endif
112#define __NR_munmap 73 /* Common */
113#define __NR_mprotect 74 /* Common */
114#define __NR_madvise 75 /* Common */
115#define __NR_vhangup 76 /* Common */
116#ifdef __32bit_syscall_numbers__
117#define __NR_truncate64 77 /* Linux sparc32 Specific */
118#endif
119#define __NR_mincore 78 /* Common */
120#define __NR_getgroups 79 /* Common */
121#define __NR_setgroups 80 /* Common */
122#define __NR_getpgrp 81 /* Common */
123#ifdef __32bit_syscall_numbers__
124#define __NR_setgroups32 82 /* Linux sparc32, setpgrp under SunOS */
125#endif
126#define __NR_setitimer 83 /* Common */
127#ifdef __32bit_syscall_numbers__
128#define __NR_ftruncate64 84 /* Linux sparc32 Specific */
129#endif
130#define __NR_swapon 85 /* Common */
131#define __NR_getitimer 86 /* Common */
132#ifdef __32bit_syscall_numbers__
133#define __NR_setuid32 87 /* Linux sparc32, gethostname under SunOS */
134#endif
135#define __NR_sethostname 88 /* Common */
136#ifdef __32bit_syscall_numbers__
137#define __NR_setgid32 89 /* Linux sparc32, getdtablesize under SunOS */
138#endif
139#define __NR_dup2 90 /* Common */
140#ifdef __32bit_syscall_numbers__
141#define __NR_setfsuid32 91 /* Linux sparc32, getdopt under SunOS */
142#endif
143#define __NR_fcntl 92 /* Common */
144#define __NR_select 93 /* Common */
145#ifdef __32bit_syscall_numbers__
146#define __NR_setfsgid32 94 /* Linux sparc32, setdopt under SunOS */
147#endif
148#define __NR_fsync 95 /* Common */
149#define __NR_setpriority 96 /* Common */
150#define __NR_socket 97 /* Common */
151#define __NR_connect 98 /* Common */
152#define __NR_accept 99 /* Common */
153#define __NR_getpriority 100 /* Common */
154#define __NR_rt_sigreturn 101 /* Linux Specific */
155#define __NR_rt_sigaction 102 /* Linux Specific */
156#define __NR_rt_sigprocmask 103 /* Linux Specific */
157#define __NR_rt_sigpending 104 /* Linux Specific */
158#define __NR_rt_sigtimedwait 105 /* Linux Specific */
159#define __NR_rt_sigqueueinfo 106 /* Linux Specific */
160#define __NR_rt_sigsuspend 107 /* Linux Specific */
161#ifdef __32bit_syscall_numbers__
162#define __NR_setresuid32 108 /* Linux Specific, sigvec under SunOS */
163#define __NR_getresuid32 109 /* Linux Specific, sigblock under SunOS */
164#define __NR_setresgid32 110 /* Linux Specific, sigsetmask under SunOS */
165#define __NR_getresgid32 111 /* Linux Specific, sigpause under SunOS */
166#define __NR_setregid32 112 /* Linux sparc32, sigstack under SunOS */
167#else
168#define __NR_setresuid 108 /* Linux Specific, sigvec under SunOS */
169#define __NR_getresuid 109 /* Linux Specific, sigblock under SunOS */
170#define __NR_setresgid 110 /* Linux Specific, sigsetmask under SunOS */
171#define __NR_getresgid 111 /* Linux Specific, sigpause under SunOS */
172#endif
173#define __NR_recvmsg 113 /* Common */
174#define __NR_sendmsg 114 /* Common */
175#ifdef __32bit_syscall_numbers__
176#define __NR_getgroups32 115 /* Linux sparc32, vtrace under SunOS */
177#endif
178#define __NR_gettimeofday 116 /* Common */
179#define __NR_getrusage 117 /* Common */
180#define __NR_getsockopt 118 /* Common */
181#define __NR_getcwd 119 /* Linux Specific */
182#define __NR_readv 120 /* Common */
183#define __NR_writev 121 /* Common */
184#define __NR_settimeofday 122 /* Common */
185#define __NR_fchown 123 /* Common */
186#define __NR_fchmod 124 /* Common */
187#define __NR_recvfrom 125 /* Common */
188#define __NR_setreuid 126 /* Common */
189#define __NR_setregid 127 /* Common */
190#define __NR_rename 128 /* Common */
191#define __NR_truncate 129 /* Common */
192#define __NR_ftruncate 130 /* Common */
193#define __NR_flock 131 /* Common */
194#define __NR_lstat64 132 /* Linux Specific */
195#define __NR_sendto 133 /* Common */
196#define __NR_shutdown 134 /* Common */
197#define __NR_socketpair 135 /* Common */
198#define __NR_mkdir 136 /* Common */
199#define __NR_rmdir 137 /* Common */
200#define __NR_utimes 138 /* SunOS Specific */
201#define __NR_stat64 139 /* Linux Specific */
202#define __NR_sendfile64 140 /* adjtime under SunOS */
203#define __NR_getpeername 141 /* Common */
204#define __NR_futex 142 /* gethostid under SunOS */
205#define __NR_gettid 143 /* ENOSYS under SunOS */
206#define __NR_getrlimit 144 /* Common */
207#define __NR_setrlimit 145 /* Common */
208#define __NR_pivot_root 146 /* Linux Specific, killpg under SunOS */
209#define __NR_prctl 147 /* ENOSYS under SunOS */
210#define __NR_pciconfig_read 148 /* ENOSYS under SunOS */
211#define __NR_pciconfig_write 149 /* ENOSYS under SunOS */
212#define __NR_getsockname 150 /* Common */
213#define __NR_inotify_init 151 /* Linux specific */
214#define __NR_inotify_add_watch 152 /* Linux specific */
215#define __NR_poll 153 /* Common */
216#define __NR_getdents64 154 /* Linux specific */
217#ifdef __32bit_syscall_numbers__
218#define __NR_fcntl64 155 /* Linux sparc32 Specific */
219#endif
220#define __NR_inotify_rm_watch 156 /* Linux specific */
221#define __NR_statfs 157 /* Common */
222#define __NR_fstatfs 158 /* Common */
223#define __NR_umount 159 /* Common */
224#define __NR_sched_set_affinity 160 /* Linux specific, async_daemon under SunOS */
225#define __NR_sched_get_affinity 161 /* Linux specific, getfh under SunOS */
226#define __NR_getdomainname 162 /* SunOS Specific */
227#define __NR_setdomainname 163 /* Common */
228#ifndef __32bit_syscall_numbers__
229#define __NR_utrap_install 164 /* SYSV ABI/v9 required */
230#endif
231#define __NR_quotactl 165 /* Common */
232#define __NR_set_tid_address 166 /* Linux specific, exportfs under SunOS */
233#define __NR_mount 167 /* Common */
234#define __NR_ustat 168 /* Common */
235#define __NR_setxattr 169 /* SunOS: semsys */
236#define __NR_lsetxattr 170 /* SunOS: msgsys */
237#define __NR_fsetxattr 171 /* SunOS: shmsys */
238#define __NR_getxattr 172 /* SunOS: auditsys */
239#define __NR_lgetxattr 173 /* SunOS: rfssys */
240#define __NR_getdents 174 /* Common */
241#define __NR_setsid 175 /* Common */
242#define __NR_fchdir 176 /* Common */
243#define __NR_fgetxattr 177 /* SunOS: fchroot */
244#define __NR_listxattr 178 /* SunOS: vpixsys */
245#define __NR_llistxattr 179 /* SunOS: aioread */
246#define __NR_flistxattr 180 /* SunOS: aiowrite */
247#define __NR_removexattr 181 /* SunOS: aiowait */
248#define __NR_lremovexattr 182 /* SunOS: aiocancel */
249#define __NR_sigpending 183 /* Common */
250#define __NR_query_module 184 /* Linux Specific */
251#define __NR_setpgid 185 /* Common */
252#define __NR_fremovexattr 186 /* SunOS: pathconf */
253#define __NR_tkill 187 /* SunOS: fpathconf */
254#define __NR_exit_group 188 /* Linux specific, sysconf undef SunOS */
255#define __NR_uname 189 /* Linux Specific */
256#define __NR_init_module 190 /* Linux Specific */
257#define __NR_personality 191 /* Linux Specific */
258#define __NR_remap_file_pages 192 /* Linux Specific */
259#define __NR_epoll_create 193 /* Linux Specific */
260#define __NR_epoll_ctl 194 /* Linux Specific */
261#define __NR_epoll_wait 195 /* Linux Specific */
262#define __NR_ioprio_set 196 /* Linux Specific */
263#define __NR_getppid 197 /* Linux Specific */
264#define __NR_sigaction 198 /* Linux Specific */
265#define __NR_sgetmask 199 /* Linux Specific */
266#define __NR_ssetmask 200 /* Linux Specific */
267#define __NR_sigsuspend 201 /* Linux Specific */
268#define __NR_oldlstat 202 /* Linux Specific */
269#define __NR_uselib 203 /* Linux Specific */
270#define __NR_readdir 204 /* Linux Specific */
271#define __NR_readahead 205 /* Linux Specific */
272#define __NR_socketcall 206 /* Linux Specific */
273#define __NR_syslog 207 /* Linux Specific */
274#define __NR_lookup_dcookie 208 /* Linux Specific */
275#define __NR_fadvise64 209 /* Linux Specific */
276#define __NR_fadvise64_64 210 /* Linux Specific */
277#define __NR_tgkill 211 /* Linux Specific */
278#define __NR_waitpid 212 /* Linux Specific */
279#define __NR_swapoff 213 /* Linux Specific */
280#define __NR_sysinfo 214 /* Linux Specific */
281#define __NR_ipc 215 /* Linux Specific */
282#define __NR_sigreturn 216 /* Linux Specific */
283#define __NR_clone 217 /* Linux Specific */
284#define __NR_ioprio_get 218 /* Linux Specific */
285#define __NR_adjtimex 219 /* Linux Specific */
286#define __NR_sigprocmask 220 /* Linux Specific */
287#define __NR_create_module 221 /* Linux Specific */
288#define __NR_delete_module 222 /* Linux Specific */
289#define __NR_get_kernel_syms 223 /* Linux Specific */
290#define __NR_getpgid 224 /* Linux Specific */
291#define __NR_bdflush 225 /* Linux Specific */
292#define __NR_sysfs 226 /* Linux Specific */
293#define __NR_afs_syscall 227 /* Linux Specific */
294#define __NR_setfsuid 228 /* Linux Specific */
295#define __NR_setfsgid 229 /* Linux Specific */
296#define __NR__newselect 230 /* Linux Specific */
297#ifdef __32bit_syscall_numbers__
298#define __NR_time 231 /* Linux Specific */
299#else
300#endif
301#define __NR_splice 232 /* Linux Specific */
302#define __NR_stime 233 /* Linux Specific */
303#define __NR_statfs64 234 /* Linux Specific */
304#define __NR_fstatfs64 235 /* Linux Specific */
305#define __NR__llseek 236 /* Linux Specific */
306#define __NR_mlock 237
307#define __NR_munlock 238
308#define __NR_mlockall 239
309#define __NR_munlockall 240
310#define __NR_sched_setparam 241
311#define __NR_sched_getparam 242
312#define __NR_sched_setscheduler 243
313#define __NR_sched_getscheduler 244
314#define __NR_sched_yield 245
315#define __NR_sched_get_priority_max 246
316#define __NR_sched_get_priority_min 247
317#define __NR_sched_rr_get_interval 248
318#define __NR_nanosleep 249
319#define __NR_mremap 250
320#define __NR__sysctl 251
321#define __NR_getsid 252
322#define __NR_fdatasync 253
323#define __NR_nfsservctl 254
324#define __NR_sync_file_range 255
325#define __NR_clock_settime 256
326#define __NR_clock_gettime 257
327#define __NR_clock_getres 258
328#define __NR_clock_nanosleep 259
329#define __NR_sched_getaffinity 260
330#define __NR_sched_setaffinity 261
331#define __NR_timer_settime 262
332#define __NR_timer_gettime 263
333#define __NR_timer_getoverrun 264
334#define __NR_timer_delete 265
335#define __NR_timer_create 266
336/* #define __NR_vserver 267 Reserved for VSERVER */
337#define __NR_io_setup 268
338#define __NR_io_destroy 269
339#define __NR_io_submit 270
340#define __NR_io_cancel 271
341#define __NR_io_getevents 272
342#define __NR_mq_open 273
343#define __NR_mq_unlink 274
344#define __NR_mq_timedsend 275
345#define __NR_mq_timedreceive 276
346#define __NR_mq_notify 277
347#define __NR_mq_getsetattr 278
348#define __NR_waitid 279
349#define __NR_tee 280
350#define __NR_add_key 281
351#define __NR_request_key 282
352#define __NR_keyctl 283
353#define __NR_openat 284
354#define __NR_mkdirat 285
355#define __NR_mknodat 286
356#define __NR_fchownat 287
357#define __NR_futimesat 288
358#define __NR_fstatat64 289
359#define __NR_unlinkat 290
360#define __NR_renameat 291
361#define __NR_linkat 292
362#define __NR_symlinkat 293
363#define __NR_readlinkat 294
364#define __NR_fchmodat 295
365#define __NR_faccessat 296
366#define __NR_pselect6 297
367#define __NR_ppoll 298
368#define __NR_unshare 299
369#define __NR_set_robust_list 300
370#define __NR_get_robust_list 301
371#define __NR_migrate_pages 302
372#define __NR_mbind 303
373#define __NR_get_mempolicy 304
374#define __NR_set_mempolicy 305
375#define __NR_kexec_load 306
376#define __NR_move_pages 307
377#define __NR_getcpu 308
378#define __NR_epoll_pwait 309
379#define __NR_utimensat 310
380#define __NR_signalfd 311
381#define __NR_timerfd_create 312
382#define __NR_eventfd 313
383#define __NR_fallocate 314
384#define __NR_timerfd_settime 315
385#define __NR_timerfd_gettime 316
386#define __NR_signalfd4 317
387#define __NR_eventfd2 318
388#define __NR_epoll_create1 319
389#define __NR_dup3 320
390#define __NR_pipe2 321
391#define __NR_inotify_init1 322
392#define __NR_accept4 323
393#define __NR_preadv 324
394#define __NR_pwritev 325
395#define __NR_rt_tgsigqueueinfo 326
396#define __NR_perf_event_open 327
397#define __NR_recvmmsg 328
398#define __NR_fanotify_init 329
399#define __NR_fanotify_mark 330
400#define __NR_prlimit64 331
401#define __NR_name_to_handle_at 332
402#define __NR_open_by_handle_at 333
403#define __NR_clock_adjtime 334
404#define __NR_syncfs 335
405#define __NR_sendmmsg 336
406#define __NR_setns 337
407#define __NR_process_vm_readv 338
408#define __NR_process_vm_writev 339
409#define __NR_kern_features 340
410#define __NR_kcmp 341
411#define __NR_finit_module 342
412#define __NR_sched_setattr 343
413#define __NR_sched_getattr 344
414#define __NR_renameat2 345
415#define __NR_seccomp 346
416#define __NR_getrandom 347
417#define __NR_memfd_create 348
418#define __NR_bpf 349
419#define __NR_execveat 350
420#define __NR_membarrier 351
421#define __NR_userfaultfd 352
422#define __NR_bind 353
423#define __NR_listen 354
424#define __NR_setsockopt 355
425#define __NR_mlock2 356
426#define __NR_copy_file_range 357
427#define __NR_preadv2 358
428#define __NR_pwritev2 359
429#define __NR_statx 360
430#define __NR_io_pgetevents 361
431
432#define NR_syscalls 362
433
434/* Bitmask values returned from kern_features system call. */
435#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
436
437#ifdef __32bit_syscall_numbers__
438/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
439 * it never had the plain ones and there is no value to adding those
440 * old versions into the syscall table.
441 */
442#define __IGNORE_setresuid
443#define __IGNORE_getresuid
444#define __IGNORE_setresgid
445#define __IGNORE_getresgid
446#endif
447
448/* Sparc doesn't have protection keys. */
449#define __IGNORE_pkey_mprotect
450#define __IGNORE_pkey_alloc
451#define __IGNORE_pkey_free
452
453#endif /* _UAPI_SPARC_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/sparc/bits/stat.h created+173
...@@ -0,0 +1,173 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_LINUX_OLD 1
27#define _STAT_VER_KERNEL 1
28#define _STAT_VER_SVR4 2
29#define _STAT_VER_LINUX 3
30#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
31
32/* Versions of the `xmknod' interface. */
33#define _MKNOD_VER_LINUX 1
34#define _MKNOD_VER_SVR4 2
35#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36
37
38struct stat
39 {
40 __dev_t st_dev; /* Device. */
41#if __WORDSIZE == 64 || !defined __USE_FILE_OFFSET64
42 unsigned short int __pad1;
43 __ino_t st_ino; /* File serial number. */
44#else
45 __ino64_t st_ino; /* File serial number. */
46#endif
47 __mode_t st_mode; /* File mode. */
48 __nlink_t st_nlink; /* Link count. */
49 __uid_t st_uid; /* User ID of the file's owner. */
50 __gid_t st_gid; /* Group ID of the file's group.*/
51 __dev_t st_rdev; /* Device number, if device. */
52 unsigned short int __pad2;
53#ifndef __USE_FILE_OFFSET64
54 __off_t st_size; /* Size of file, in bytes. */
55#else
56 __off64_t st_size; /* Size of file, in bytes. */
57#endif
58 __blksize_t st_blksize; /* Optimal block size for I/O. */
59
60#ifndef __USE_FILE_OFFSET64
61 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
62#else
63 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86 unsigned long int __glibc_reserved4;
87 unsigned long int __glibc_reserved5;
88 };
89
90#ifdef __USE_LARGEFILE64
91struct stat64
92 {
93 __dev_t st_dev; /* Device. */
94# if __WORDSIZE == 64
95 unsigned short int __pad1;
96# endif
97 __ino64_t st_ino; /* File serial number. */
98 __mode_t st_mode; /* File mode. */
99 __nlink_t st_nlink; /* Link count. */
100 __uid_t st_uid; /* User ID of the file's owner. */
101 __gid_t st_gid; /* Group ID of the file's group.*/
102 __dev_t st_rdev; /* Device number, if device. */
103 unsigned short int __pad2;
104 __off64_t st_size; /* Size of file, in bytes. */
105 __blksize_t st_blksize; /* Optimal block size for I/O. */
106
107 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
108# ifdef __USE_XOPEN2K8
109 /* Nanosecond resolution timestamps are stored in a format
110 equivalent to 'struct timespec'. This is the type used
111 whenever possible but the Unix namespace rules do not allow the
112 identifier 'timespec' to appear in the <sys/stat.h> header.
113 Therefore we have to handle the use of this header in strictly
114 standard-compliant sources special. */
115 struct timespec st_atim; /* Time of last access. */
116 struct timespec st_mtim; /* Time of last modification. */
117 struct timespec st_ctim; /* Time of last status change. */
118# define st_atime st_atim.tv_sec /* Backward compatibility. */
119# define st_mtime st_mtim.tv_sec
120# define st_ctime st_ctim.tv_sec
121# else
122 __time_t st_atime; /* Time of last access. */
123 unsigned long int st_atimensec; /* Nscecs of last access. */
124 __time_t st_mtime; /* Time of last modification. */
125 unsigned long int st_mtimensec; /* Nsecs of last modification. */
126 __time_t st_ctime; /* Time of last status change. */
127 unsigned long int st_ctimensec; /* Nsecs of last status change. */
128# endif
129 unsigned long int __glibc_reserved4;
130 unsigned long int __glibc_reserved5;
131 };
132#endif
133
134/* Tell code we have these members. */
135#define _STATBUF_ST_BLKSIZE
136#define _STATBUF_ST_RDEV
137/* Nanosecond resolution time values are supported. */
138#define _STATBUF_ST_NSEC
139
140/* Encoding of the file mode. */
141
142#define __S_IFMT 0170000 /* These bits determine file type. */
143
144/* File types. */
145#define __S_IFDIR 0040000 /* Directory. */
146#define __S_IFCHR 0020000 /* Character device. */
147#define __S_IFBLK 0060000 /* Block device. */
148#define __S_IFREG 0100000 /* Regular file. */
149#define __S_IFIFO 0010000 /* FIFO. */
150#define __S_IFLNK 0120000 /* Symbolic link. */
151#define __S_IFSOCK 0140000 /* Socket. */
152
153/* POSIX.1b objects. Note that these macros always evaluate to zero. But
154 they do it by enforcing the correct use of the macros. */
155#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
156#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
157#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
158
159/* Protection bits. */
160
161#define __S_ISUID 04000 /* Set user ID on execution. */
162#define __S_ISGID 02000 /* Set group ID on execution. */
163#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
164#define __S_IREAD 0400 /* Read by owner. */
165#define __S_IWRITE 0200 /* Write by owner. */
166#define __S_IEXEC 0100 /* Execute by owner. */
167
168#ifdef __USE_ATFILE
169# define UTIME_NOW ((1l << 30) - 1l)
170# define UTIME_OMIT ((1l << 30) - 2l)
171#endif
172
173#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h created+83
...@@ -0,0 +1,83 @@
1/* bits/typesizes.h -- underlying types for *_t. Linux/SPARC version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29#define __DEV_T_TYPE __UQUAD_TYPE
30#define __UID_T_TYPE __U32_TYPE
31#define __GID_T_TYPE __U32_TYPE
32#define __INO_T_TYPE __ULONGWORD_TYPE
33#define __INO64_T_TYPE __UQUAD_TYPE
34#define __MODE_T_TYPE __U32_TYPE
35#define __NLINK_T_TYPE __U32_TYPE
36#define __OFF_T_TYPE __SLONGWORD_TYPE
37#define __OFF64_T_TYPE __SQUAD_TYPE
38#define __PID_T_TYPE __S32_TYPE
39#define __RLIM_T_TYPE __ULONGWORD_TYPE
40#define __RLIM64_T_TYPE __UQUAD_TYPE
41#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
42#define __BLKCNT64_T_TYPE __SQUAD_TYPE
43#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
44#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
45#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
46#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
47#define __FSWORD_T_TYPE __SWORD_TYPE
48#define __ID_T_TYPE __U32_TYPE
49#define __CLOCK_T_TYPE __SLONGWORD_TYPE
50#define __TIME_T_TYPE __SLONGWORD_TYPE
51#define __USECONDS_T_TYPE __U32_TYPE
52#define __SUSECONDS_T_TYPE __S32_TYPE
53#define __DADDR_T_TYPE __S32_TYPE
54#define __KEY_T_TYPE __S32_TYPE
55#define __CLOCKID_T_TYPE __S32_TYPE
56#define __TIMER_T_TYPE void *
57#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
58#define __FSID_T_TYPE struct { int __val[2]; }
59#define __SSIZE_T_TYPE __SWORD_TYPE
60#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
61#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
62#define __CPU_MASK_TYPE __ULONGWORD_TYPE
63
64#if defined __arch64__ || defined __sparcv9
65/* Tell the libc code that off_t and off64_t are actually the same type
66 for all ABI purposes, even if possibly expressed as different base types
67 for C type-checking purposes. */
68# define __OFF_T_MATCHES_OFF64_T 1
69
70/* Same for ino_t and ino64_t. */
71# define __INO_T_MATCHES_INO64_T 1
72
73/* And for __rlim_t and __rlim64_t. */
74# define __RLIM_T_MATCHES_RLIM64_T 1
75#else
76# define __RLIM_T_MATCHES_RLIM64_T 0
77#endif
78
79/* Number of descriptors that can fit in an `fd_set'. */
80#define __FD_SETSIZE 1024
81
82
83#endif /* bits/typesizes.h */
libc/glibc/sysdeps/unix/sysv/linux/sparc/kernel-features.h created+81
...@@ -0,0 +1,81 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. SPARC version.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include_next <kernel-features.h>
21
22/* 32-bit SPARC kernels do not support
23 futex_atomic_cmpxchg_inatomic. */
24#if !defined __arch64__ && !defined __sparc_v9__
25# undef __ASSUME_SET_ROBUST_LIST
26#endif
27
28/* These syscalls were added for 32-bit in 4.4 (but present for 64-bit
29 in all supported kernel versions); the architecture-independent
30 kernel-features.h assumes some of them to be present by default.
31 getpeername and getsockname syscalls were also added for 32-bit in
32 4.4, but only for 32-bit kernels, not in the compat syscall table
33 for 64-bit kernels. */
34#if !defined __arch64__ && __LINUX_KERNEL_VERSION < 0x040400
35# undef __ASSUME_SENDMSG_SYSCALL
36# undef __ASSUME_RECVMSG_SYSCALL
37# undef __ASSUME_ACCEPT_SYSCALL
38# undef __ASSUME_CONNECT_SYSCALL
39# undef __ASSUME_RECVFROM_SYSCALL
40# undef __ASSUME_SENDTO_SYSCALL
41#else
42# define __ASSUME_SOCKET_SYSCALL 1
43# define __ASSUME_SOCKETPAIR_SYSCALL 1
44# define __ASSUME_GETSOCKOPT_SYSCALL 1
45# define __ASSUME_SHUTDOWN_SYSCALL 1
46#endif
47
48/* These syscalls were added for both 32-bit and 64-bit in 4.4. */
49#if __LINUX_KERNEL_VERSION >= 0x040400
50# define __ASSUME_BIND_SYSCALL 1
51# define __ASSUME_LISTEN_SYSCALL 1
52# define __ASSUME_SETSOCKOPT_SYSCALL 1
53#endif
54
55#ifdef __arch64__
56/* sparc64 defines __NR_pause, however it is not supported (ENOSYS).
57 Undefine so pause.c can use a correct alternative. */
58# undef __NR_pause
59#endif
60
61/* sparc only supports ipc syscall. */
62#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
63
64/* Support for the renameat2 syscall was added in 3.16. */
65#if __LINUX_KERNEL_VERSION < 0x031000
66# undef __ASSUME_RENAMEAT2
67#endif
68
69/* SPARC kernel Kconfig does not define CONFIG_CLONE_BACKWARDS, however it
70 has the same ABI as if it did, implemented by sparc-specific code
71 (sparc_do_fork).
72
73 It also has a unique return value convention:
74
75 Parent --> %o0 == child's pid, %o1 == 0
76 Child --> %o0 == parent's pid, %o1 == 1
77
78 Which required a special macro to correct issue the syscall
79 (INLINE_CLONE_SYSCALL). */
80#undef __ASSUME_CLONE_DEFAULT
81#define __ASSUME_CLONE_BACKWARDS 1
libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h created+147
...@@ -0,0 +1,147 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_SPARC32_SYSDEP_H
20#define _LINUX_SPARC32_SYSDEP_H 1
21
22#include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
23
24#if IS_IN (rtld)
25# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
26#endif
27#include <tls.h>
28
29#undef SYS_ify
30#define SYS_ify(syscall_name) __NR_##syscall_name
31
32#ifdef __ASSEMBLER__
33
34#define LOADSYSCALL(x) mov __NR_##x, %g1
35
36#undef PSEUDO
37#define PSEUDO(name, syscall_name, args) \
38 .text; \
39ENTRY(name); \
40 LOADSYSCALL(syscall_name); \
41 ta 0x10; \
42 bcc 1f; \
43 nop; \
44 SYSCALL_ERROR_HANDLER \
451:
46
47#undef PSEUDO_NOERRNO
48#define PSEUDO_NOERRNO(name, syscall_name, args)\
49 .text; \
50ENTRY(name); \
51 LOADSYSCALL(syscall_name); \
52 ta 0x10;
53
54#undef PSEUDO_ERRVAL
55#define PSEUDO_ERRVAL(name, syscall_name, args) \
56 .text; \
57ENTRY(name); \
58 LOADSYSCALL(syscall_name); \
59 ta 0x10;
60
61#undef PSEUDO_END
62#define PSEUDO_END(name) \
63 END(name)
64
65#ifndef PIC
66# define SYSCALL_ERROR_HANDLER \
67 mov %o7, %g1; \
68 call __syscall_error; \
69 mov %g1, %o7;
70#else
71# if RTLD_PRIVATE_ERRNO
72# define SYSCALL_ERROR_HANDLER \
730: SETUP_PIC_REG_LEAF(o2,g1) \
74 sethi %gdop_hix22(rtld_errno), %g1; \
75 xor %g1, %gdop_lox10(rtld_errno), %g1;\
76 ld [%o2 + %g1], %g1, %gdop(rtld_errno); \
77 st %o0, [%g1]; \
78 jmp %o7 + 8; \
79 mov -1, %o0;
80# elif defined _LIBC_REENTRANT
81
82# if IS_IN (libc)
83# define SYSCALL_ERROR_ERRNO __libc_errno
84# else
85# define SYSCALL_ERROR_ERRNO errno
86# endif
87# define SYSCALL_ERROR_HANDLER \
880: SETUP_PIC_REG_LEAF(o2,g1) \
89 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
90 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
91 ld [%o2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO); \
92 st %o0, [%g7 + %g1]; \
93 jmp %o7 + 8; \
94 mov -1, %o0;
95# else
96# define SYSCALL_ERROR_HANDLER \
970: SETUP_PIC_REG_LEAF(o2,g1) \
98 sethi %gdop_hix22(errno), %g1;\
99 xor %g1, %gdop_lox10(errno), %g1;\
100 ld [%o2 + %g1], %g1, %gdop(errno);\
101 st %o0, [%g1]; \
102 jmp %o7 + 8; \
103 mov -1, %o0;
104# endif /* _LIBC_REENTRANT */
105#endif /* PIC */
106
107
108#else /* __ASSEMBLER__ */
109
110#define __SYSCALL_STRING \
111 "ta 0x10;" \
112 "bcc 1f;" \
113 " mov 0, %%g1;" \
114 "sub %%g0, %%o0, %%o0;" \
115 "mov 1, %%g1;" \
116 "1:"
117
118#define __SYSCALL_CLOBBERS \
119 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
120 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
121 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
122 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
123 "cc", "memory"
124
125#endif /* __ASSEMBLER__ */
126
127/* Pointer mangling support. */
128#if IS_IN (rtld)
129/* We cannot use the thread descriptor because in ld.so we use setjmp
130 earlier than the descriptor is initialized. */
131#else
132# ifdef __ASSEMBLER__
133# define PTR_MANGLE(dreg, reg, tmpreg) \
134 ld [%g7 + POINTER_GUARD], tmpreg; \
135 xor reg, tmpreg, dreg
136# define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
137# define PTR_MANGLE2(dreg, reg, tmpreg) \
138 xor reg, tmpreg, dreg
139# define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
140# else
141# define PTR_MANGLE(var) \
142 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
143# define PTR_DEMANGLE(var) PTR_MANGLE (var)
144# endif
145#endif
146
147#endif /* linux/sparc/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h created+162
...@@ -0,0 +1,162 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_SPARC64_SYSDEP_H
20#define _LINUX_SPARC64_SYSDEP_H 1
21
22#include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
23
24#if IS_IN (rtld)
25# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
26#endif
27#include <tls.h>
28
29#undef SYS_ify
30#define SYS_ify(syscall_name) __NR_##syscall_name
31
32/* This is a kludge to make syscalls.list find these under the names
33 pread and pwrite, since some kernel headers define those names
34 and some define the *64 names for the same system calls. */
35#if !defined __NR_pread && defined __NR_pread64
36# define __NR_pread __NR_pread64
37#endif
38#if !defined __NR_pwrite && defined __NR_pwrite64
39# define __NR_pwrite __NR_pwrite64
40#endif
41
42#ifdef __ASSEMBLER__
43
44#define LOADSYSCALL(x) mov __NR_##x, %g1
45
46#undef PSEUDO
47#define PSEUDO(name, syscall_name, args) \
48 .text; \
49ENTRY(name); \
50 LOADSYSCALL(syscall_name); \
51 ta 0x6d; \
52 bcc,pt %xcc, 1f; \
53 nop; \
54 SYSCALL_ERROR_HANDLER \
551:
56
57#undef PSEUDO_NOERRNO
58#define PSEUDO_NOERRNO(name, syscall_name, args)\
59 .text; \
60ENTRY(name); \
61 LOADSYSCALL(syscall_name); \
62 ta 0x6d;
63
64#undef PSEUDO_ERRVAL
65#define PSEUDO_ERRVAL(name, syscall_name, args) \
66 .text; \
67ENTRY(name); \
68 LOADSYSCALL(syscall_name); \
69 ta 0x6d;
70
71#undef PSEUDO_END
72#define PSEUDO_END(name) \
73 END(name)
74
75#ifndef PIC
76# define SYSCALL_ERROR_HANDLER \
77 mov %o7, %g1; \
78 call __syscall_error; \
79 mov %g1, %o7;
80#else
81# if RTLD_PRIVATE_ERRNO
82# define SYSCALL_ERROR_HANDLER \
830: SETUP_PIC_REG_LEAF(o2,g1) \
84 sethi %gdop_hix22(rtld_errno), %g1; \
85 xor %g1, %gdop_lox10(rtld_errno), %g1;\
86 ldx [%o2 + %g1], %g1, %gdop(rtld_errno); \
87 st %o0, [%g1]; \
88 jmp %o7 + 8; \
89 mov -1, %o0;
90# elif defined _LIBC_REENTRANT
91
92# if IS_IN (libc)
93# define SYSCALL_ERROR_ERRNO __libc_errno
94# else
95# define SYSCALL_ERROR_ERRNO errno
96# endif
97# define SYSCALL_ERROR_HANDLER \
980: SETUP_PIC_REG_LEAF(o2,g1) \
99 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
100 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
101 ldx [%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\
102 st %o0, [%g7 + %g1]; \
103 jmp %o7 + 8; \
104 mov -1, %o0;
105# else
106# define SYSCALL_ERROR_HANDLER \
1070: SETUP_PIC_REG_LEAF(o2,g1) \
108 sethi %gdop_hix22(errno), %g1;\
109 xor %g1, %gdop_lox10(errno), %g1;\
110 ldx [%o2 + %g1], %g1, %gdop(errno);\
111 st %o0, [%g1]; \
112 jmp %o7 + 8; \
113 mov -1, %o0;
114# endif /* _LIBC_REENTRANT */
115#endif /* PIC */
116
117#else /* __ASSEMBLER__ */
118
119#define __SYSCALL_STRING \
120 "ta 0x6d;" \
121 "bcc,pt %%xcc, 1f;" \
122 " mov 0, %%g1;" \
123 "sub %%g0, %%o0, %%o0;" \
124 "mov 1, %%g1;" \
125 "1:"
126
127#define __SYSCALL_CLOBBERS \
128 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
129 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
130 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
131 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
132 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
133 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \
134 "cc", "memory"
135
136#endif /* __ASSEMBLER__ */
137
138/* This is the offset from the %sp to the backing store above the
139 register windows. So if you poke stack memory directly you add this. */
140#define STACK_BIAS 2047
141
142/* Pointer mangling support. */
143#if IS_IN (rtld)
144/* We cannot use the thread descriptor because in ld.so we use setjmp
145 earlier than the descriptor is initialized. */
146#else
147# ifdef __ASSEMBLER__
148# define PTR_MANGLE(dreg, reg, tmpreg) \
149 ldx [%g7 + POINTER_GUARD], tmpreg; \
150 xor reg, tmpreg, dreg
151# define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
152# define PTR_MANGLE2(dreg, reg, tmpreg) \
153 xor reg, tmpreg, dreg
154# define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
155# else
156# define PTR_MANGLE(var) \
157 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
158# define PTR_DEMANGLE(var) PTR_MANGLE (var)
159# endif
160#endif
161
162#endif /* linux/sparc64/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/sparc/sysdep.h created+196
...@@ -0,0 +1,196 @@
1/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LINUX_SPARC_SYSDEP_H
20#define _LINUX_SPARC_SYSDEP_H 1
21
22#include <sysdeps/unix/sysdep.h>
23#include <sysdeps/unix/sysv/linux/sysdep.h>
24#include <sysdeps/sparc/sysdep.h>
25
26#ifdef __ASSEMBLER__
27
28#define ret retl; nop
29#define ret_NOERRNO retl; nop
30#define ret_ERRVAL retl; nop
31#define r0 %o0
32#define r1 %o1
33#define MOVE(x,y) mov x, y
34
35#else /* __ASSEMBLER__ */
36
37#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
38 ({ \
39 long _ret = funcptr (args); \
40 err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \
41 _ret; \
42 })
43
44/* List of system calls which are supported as vsyscalls. */
45# define HAVE_CLOCK_GETTIME_VSYSCALL 1
46# define HAVE_GETTIMEOFDAY_VSYSCALL 1
47
48#undef INLINE_SYSCALL
49#define INLINE_SYSCALL(name, nr, args...) \
50({ INTERNAL_SYSCALL_DECL(err); \
51 unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args);\
52 if (INTERNAL_SYSCALL_ERROR_P (resultvar, err)) \
53 { \
54 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err)); \
55 resultvar = (unsigned long) -1; \
56 } \
57 (long) resultvar; \
58})
59
60#undef INTERNAL_SYSCALL_DECL
61#define INTERNAL_SYSCALL_DECL(err) \
62 register long err __asm__("g1");
63
64#undef INTERNAL_SYSCALL
65#define INTERNAL_SYSCALL(name, err, nr, args...) \
66 inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
67
68#undef INTERNAL_SYSCALL_NCS
69#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
70 inline_syscall##nr(__SYSCALL_STRING, err, name, args)
71
72#undef INTERNAL_SYSCALL_ERROR_P
73#define INTERNAL_SYSCALL_ERROR_P(val, err) \
74 ((void) (val), __builtin_expect((err) != 0, 0))
75
76#undef INTERNAL_SYSCALL_ERRNO
77#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
78
79#define inline_syscall0(string,err,name,dummy...) \
80({ \
81 register long __o0 __asm__ ("o0"); \
82 err = name; \
83 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
84 "0" (err) : \
85 __SYSCALL_CLOBBERS); \
86 __o0; \
87})
88
89#define inline_syscall1(string,err,name,arg1) \
90({ \
91 register long __o0 __asm__ ("o0") = (long)(arg1); \
92 err = name; \
93 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
94 "0" (err), "1" (__o0) : \
95 __SYSCALL_CLOBBERS); \
96 __o0; \
97})
98
99#define inline_syscall2(string,err,name,arg1,arg2) \
100({ \
101 register long __o0 __asm__ ("o0") = (long)(arg1); \
102 register long __o1 __asm__ ("o1") = (long)(arg2); \
103 err = name; \
104 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
105 "0" (err), "1" (__o0), "r" (__o1) : \
106 __SYSCALL_CLOBBERS); \
107 __o0; \
108})
109
110#define inline_syscall3(string,err,name,arg1,arg2,arg3) \
111({ \
112 register long __o0 __asm__ ("o0") = (long)(arg1); \
113 register long __o1 __asm__ ("o1") = (long)(arg2); \
114 register long __o2 __asm__ ("o2") = (long)(arg3); \
115 err = name; \
116 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
117 "0" (err), "1" (__o0), "r" (__o1), \
118 "r" (__o2) : \
119 __SYSCALL_CLOBBERS); \
120 __o0; \
121})
122
123#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4) \
124({ \
125 register long __o0 __asm__ ("o0") = (long)(arg1); \
126 register long __o1 __asm__ ("o1") = (long)(arg2); \
127 register long __o2 __asm__ ("o2") = (long)(arg3); \
128 register long __o3 __asm__ ("o3") = (long)(arg4); \
129 err = name; \
130 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
131 "0" (err), "1" (__o0), "r" (__o1), \
132 "r" (__o2), "r" (__o3) : \
133 __SYSCALL_CLOBBERS); \
134 __o0; \
135})
136
137#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5) \
138({ \
139 register long __o0 __asm__ ("o0") = (long)(arg1); \
140 register long __o1 __asm__ ("o1") = (long)(arg2); \
141 register long __o2 __asm__ ("o2") = (long)(arg3); \
142 register long __o3 __asm__ ("o3") = (long)(arg4); \
143 register long __o4 __asm__ ("o4") = (long)(arg5); \
144 err = name; \
145 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
146 "0" (err), "1" (__o0), "r" (__o1), \
147 "r" (__o2), "r" (__o3), "r" (__o4) : \
148 __SYSCALL_CLOBBERS); \
149 __o0; \
150})
151
152#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6) \
153({ \
154 register long __o0 __asm__ ("o0") = (long)(arg1); \
155 register long __o1 __asm__ ("o1") = (long)(arg2); \
156 register long __o2 __asm__ ("o2") = (long)(arg3); \
157 register long __o3 __asm__ ("o3") = (long)(arg4); \
158 register long __o4 __asm__ ("o4") = (long)(arg5); \
159 register long __o5 __asm__ ("o5") = (long)(arg6); \
160 err = name; \
161 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
162 "0" (err), "1" (__o0), "r" (__o1), \
163 "r" (__o2), "r" (__o3), "r" (__o4), \
164 "r" (__o5) : \
165 __SYSCALL_CLOBBERS); \
166 __o0; \
167})
168
169#define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \
170({ \
171 register long __o0 __asm__ ("o0") = (long)(arg1); \
172 register long __o1 __asm__ ("o1") = (long)(arg2); \
173 register long __o2 __asm__ ("o2") = (long)(arg3); \
174 register long __o3 __asm__ ("o3") = (long)(arg4); \
175 register long __o4 __asm__ ("o4") = (long)(arg5); \
176 register long __g1 __asm__ ("g1") = __NR_clone; \
177 __asm __volatile (__SYSCALL_STRING : \
178 "=r" (__g1), "=r" (__o0), "=r" (__o1) : \
179 "0" (__g1), "1" (__o0), "2" (__o1), \
180 "r" (__o2), "r" (__o3), "r" (__o4) : \
181 __SYSCALL_CLOBBERS); \
182 if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1)) \
183 { \
184 __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1)); \
185 __o0 = -1L; \
186 } \
187 else \
188 { \
189 __o0 &= (__o1 - 1); \
190 } \
191 __o0; \
192})
193
194#endif /* __ASSEMBLER__ */
195
196#endif /* _LINUX_SPARC_SYSDEP_H */
libc/glibc/sysdeps/unix/sysv/linux/sys/syscall.h created+34
...@@ -0,0 +1,34 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYSCALL_H
19#define _SYSCALL_H 1
20
21/* This file should list the numbers of the system calls the system knows.
22 But instead of duplicating this we use the information available
23 from the kernel sources. */
24#include <asm/unistd.h>
25
26#ifndef _LIBC
27/* The Linux kernel header file defines macros `__NR_<name>', but some
28 programs expect the traditional form `SYS_<name>'. So in building libc
29 we scan the kernel's list and produce <bits/syscall.h> with macros for
30 all the `SYS_' names. */
31# include <bits/syscall.h>
32#endif
33
34#endif
libc/glibc/sysdeps/unix/sysv/linux/sysdep.h created+75
...@@ -0,0 +1,75 @@
1/* Copyright (C) 2015-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <bits/wordsize.h>
19#include <kernel-features.h>
20
21/* By default only shared builds use vdso. */
22#ifndef ALWAYS_USE_VSYSCALL
23#define ALWAYS_USE_VSYSCALL 0
24#endif
25
26#define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL)
27
28/* Set error number and return -1. A target may choose to return the
29 internal function, __syscall_error, which sets errno and returns -1.
30 We use -1l, instead of -1, so that it can be casted to (void *). */
31#define INLINE_SYSCALL_ERROR_RETURN_VALUE(err) \
32 ({ \
33 __set_errno (err); \
34 -1l; \
35 })
36
37/* Provide a dummy argument that can be used to force register
38 alignment for register pairs if required by the syscall ABI. */
39#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
40#define __ALIGNMENT_ARG 0,
41#define __ALIGNMENT_COUNT(a,b) b
42#else
43#define __ALIGNMENT_ARG
44#define __ALIGNMENT_COUNT(a,b) a
45#endif
46
47/* Provide a common macro to pass 64-bit value on syscalls. */
48#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
49# define SYSCALL_LL(val) (val)
50# define SYSCALL_LL64(val) (val)
51#else
52#define SYSCALL_LL(val) \
53 __LONG_LONG_PAIR ((val) >> 31, (val))
54#define SYSCALL_LL64(val) \
55 __LONG_LONG_PAIR ((long) ((val) >> 32), (long) ((val) & 0xffffffff))
56#endif
57
58/* Provide a common macro to pass 64-bit value on pread and pwrite
59 syscalls. */
60#ifdef __ASSUME_PRW_DUMMY_ARG
61# define SYSCALL_LL_PRW(val) 0, SYSCALL_LL (val)
62# define SYSCALL_LL64_PRW(val) 0, SYSCALL_LL64 (val)
63#else
64# define SYSCALL_LL_PRW(val) __ALIGNMENT_ARG SYSCALL_LL (val)
65# define SYSCALL_LL64_PRW(val) __ALIGNMENT_ARG SYSCALL_LL64 (val)
66#endif
67
68/* Provide a macro to pass the off{64}_t argument on p{readv,writev}{64}. */
69#define LO_HI_LONG(val) \
70 (long) (val), \
71 (long) (((uint64_t) (val)) >> 32)
72
73/* Exports the __send symbol on send.c linux implementation (some ABI have
74 it missing due the usage of a old generic version without it). */
75#define HAVE_INTERNAL_SEND_SYMBOL 1
libc/glibc/sysdeps/unix/sysv/linux/x86/asm/unistd.h created+18
...@@ -0,0 +1,18 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef _UAPI_ASM_X86_UNISTD_H
3#define _UAPI_ASM_X86_UNISTD_H
4
5/* x32 syscall flag bit */
6#define __X32_SYSCALL_BIT 0x40000000
7
8#ifndef __KERNEL__
9# ifdef __i386__
10# include <asm/unistd_32.h>
11# elif defined(__ILP32__)
12# include <asm/unistd_x32.h>
13# else
14# include <asm/unistd_64.h>
15# endif
16#endif
17
18#endif /* _UAPI_ASM_X86_UNISTD_H */
libc/glibc/sysdeps/unix/sysv/linux/x86_64/kernel-features.h created+26
...@@ -0,0 +1,26 @@
1/* Set flags signalling availability of kernel features based on given
2 kernel version number. x86-64 version.
3 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* Define that x32 is a ILP32 ABI to set the correct interface to pass
21 64-bits values through syscalls. */
22#ifdef __ILP32__
23# define __ASSUME_WORDSIZE64_ILP32 1
24#endif
25
26#include_next <kernel-features.h>
libc/glibc/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h deleted-270
...@@ -1,270 +0,0 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LOWLEVELLOCK_H
20#define _LOWLEVELLOCK_H 1
21
22#include <stap-probe.h>
23
24#ifndef __ASSEMBLER__
25# include <time.h>
26# include <sys/param.h>
27# include <bits/pthreadtypes.h>
28# include <kernel-features.h>
29
30# ifndef LOCK_INSTR
31# ifdef UP
32# define LOCK_INSTR /* nothing */
33# else
34# define LOCK_INSTR "lock;"
35# endif
36# endif
37#else
38# ifndef LOCK
39# ifdef UP
40# define LOCK
41# else
42# define LOCK lock
43# endif
44# endif
45#endif
46
47#include <lowlevellock-futex.h>
48
49/* XXX Remove when no assembler code uses futexes anymore. */
50#define SYS_futex __NR_futex
51
52#ifndef __ASSEMBLER__
53
54/* Initializer for lock. */
55#define LLL_LOCK_INITIALIZER (0)
56#define LLL_LOCK_INITIALIZER_LOCKED (1)
57#define LLL_LOCK_INITIALIZER_WAITERS (2)
58
59
60/* NB: in the lll_trylock macro we simply return the value in %eax
61 after the cmpxchg instruction. In case the operation succeded this
62 value is zero. In case the operation failed, the cmpxchg instruction
63 has loaded the current value of the memory work which is guaranteed
64 to be nonzero. */
65#if !IS_IN (libc) || defined UP
66# define __lll_trylock_asm LOCK_INSTR "cmpxchgl %2, %1"
67#else
68# define __lll_trylock_asm "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
69 "je 0f\n\t" \
70 "lock; cmpxchgl %2, %1\n\t" \
71 "jmp 1f\n\t" \
72 "0:\tcmpxchgl %2, %1\n\t" \
73 "1:"
74#endif
75
76#define lll_trylock(futex) \
77 ({ int ret; \
78 __asm __volatile (__lll_trylock_asm \
79 : "=a" (ret), "=m" (futex) \
80 : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex), \
81 "0" (LLL_LOCK_INITIALIZER) \
82 : "memory"); \
83 ret; })
84
85#define lll_cond_trylock(futex) \
86 ({ int ret; \
87 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
88 : "=a" (ret), "=m" (futex) \
89 : "r" (LLL_LOCK_INITIALIZER_WAITERS), \
90 "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
91 : "memory"); \
92 ret; })
93
94#if !IS_IN (libc) || defined UP
95# define __lll_lock_asm_start LOCK_INSTR "cmpxchgl %4, %2\n\t" \
96 "jz 24f\n\t"
97#else
98# define __lll_lock_asm_start "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
99 "je 0f\n\t" \
100 "lock; cmpxchgl %4, %2\n\t" \
101 "jnz 1f\n\t" \
102 "jmp 24f\n" \
103 "0:\tcmpxchgl %4, %2\n\t" \
104 "jz 24f\n\t"
105#endif
106
107#define lll_lock(futex, private) \
108 (void) \
109 ({ int ignore1, ignore2, ignore3; \
110 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
111 __asm __volatile (__lll_lock_asm_start \
112 "1:\tlea %2, %%" RDI_LP "\n" \
113 "2:\tsub $128, %%" RSP_LP "\n" \
114 ".cfi_adjust_cfa_offset 128\n" \
115 "3:\tcallq __lll_lock_wait_private\n" \
116 "4:\tadd $128, %%" RSP_LP "\n" \
117 ".cfi_adjust_cfa_offset -128\n" \
118 "24:" \
119 : "=S" (ignore1), "=&D" (ignore2), "=m" (futex), \
120 "=a" (ignore3) \
121 : "0" (1), "m" (futex), "3" (0) \
122 : "cx", "r11", "cc", "memory"); \
123 else \
124 __asm __volatile (__lll_lock_asm_start \
125 "1:\tlea %2, %%" RDI_LP "\n" \
126 "2:\tsub $128, %%" RSP_LP "\n" \
127 ".cfi_adjust_cfa_offset 128\n" \
128 "3:\tcallq __lll_lock_wait\n" \
129 "4:\tadd $128, %%" RSP_LP "\n" \
130 ".cfi_adjust_cfa_offset -128\n" \
131 "24:" \
132 : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
133 "=a" (ignore3) \
134 : "1" (1), "m" (futex), "3" (0), "0" (private) \
135 : "cx", "r11", "cc", "memory"); \
136 }) \
137
138#define lll_cond_lock(futex, private) \
139 (void) \
140 ({ int ignore1, ignore2, ignore3; \
141 __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
142 "jz 24f\n" \
143 "1:\tlea %2, %%" RDI_LP "\n" \
144 "2:\tsub $128, %%" RSP_LP "\n" \
145 ".cfi_adjust_cfa_offset 128\n" \
146 "3:\tcallq __lll_lock_wait\n" \
147 "4:\tadd $128, %%" RSP_LP "\n" \
148 ".cfi_adjust_cfa_offset -128\n" \
149 "24:" \
150 : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
151 "=a" (ignore3) \
152 : "1" (2), "m" (futex), "3" (0), "0" (private) \
153 : "cx", "r11", "cc", "memory"); \
154 })
155
156#define lll_timedlock(futex, timeout, private) \
157 ({ int result, ignore1, ignore2, ignore3; \
158 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %4\n\t" \
159 "jz 24f\n" \
160 "1:\tlea %4, %%" RDI_LP "\n" \
161 "0:\tmov %8, %%" RDX_LP "\n" \
162 "2:\tsub $128, %%" RSP_LP "\n" \
163 ".cfi_adjust_cfa_offset 128\n" \
164 "3:\tcallq __lll_timedlock_wait\n" \
165 "4:\tadd $128, %%" RSP_LP "\n" \
166 ".cfi_adjust_cfa_offset -128\n" \
167 "24:" \
168 : "=a" (result), "=D" (ignore1), "=S" (ignore2), \
169 "=&d" (ignore3), "=m" (futex) \
170 : "0" (0), "1" (1), "m" (futex), "m" (timeout), \
171 "2" (private) \
172 : "memory", "cx", "cc", "r10", "r11"); \
173 result; })
174
175extern int __lll_timedlock_elision (int *futex, short *adapt_count,
176 const struct timespec *timeout,
177 int private) attribute_hidden;
178
179#define lll_timedlock_elision(futex, adapt_count, timeout, private) \
180 __lll_timedlock_elision(&(futex), &(adapt_count), timeout, private)
181
182#if !IS_IN (libc) || defined UP
183# define __lll_unlock_asm_start LOCK_INSTR "decl %0\n\t" \
184 "je 24f\n\t"
185#else
186# define __lll_unlock_asm_start "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
187 "je 0f\n\t" \
188 "lock; decl %0\n\t" \
189 "jne 1f\n\t" \
190 "jmp 24f\n\t" \
191 "0:\tdecl %0\n\t" \
192 "je 24f\n\t"
193#endif
194
195#define lll_unlock(futex, private) \
196 (void) \
197 ({ int ignore; \
198 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
199 __asm __volatile (__lll_unlock_asm_start \
200 "1:\tlea %0, %%" RDI_LP "\n" \
201 "2:\tsub $128, %%" RSP_LP "\n" \
202 ".cfi_adjust_cfa_offset 128\n" \
203 "3:\tcallq __lll_unlock_wake_private\n" \
204 "4:\tadd $128, %%" RSP_LP "\n" \
205 ".cfi_adjust_cfa_offset -128\n" \
206 "24:" \
207 : "=m" (futex), "=&D" (ignore) \
208 : "m" (futex) \
209 : "ax", "cx", "r11", "cc", "memory"); \
210 else \
211 __asm __volatile (__lll_unlock_asm_start \
212 "1:\tlea %0, %%" RDI_LP "\n" \
213 "2:\tsub $128, %%" RSP_LP "\n" \
214 ".cfi_adjust_cfa_offset 128\n" \
215 "3:\tcallq __lll_unlock_wake\n" \
216 "4:\tadd $128, %%" RSP_LP "\n" \
217 ".cfi_adjust_cfa_offset -128\n" \
218 "24:" \
219 : "=m" (futex), "=&D" (ignore) \
220 : "m" (futex), "S" (private) \
221 : "ax", "cx", "r11", "cc", "memory"); \
222 })
223
224#define lll_islocked(futex) \
225 (futex != LLL_LOCK_INITIALIZER)
226
227extern int __lll_timedwait_tid (int *, const struct timespec *)
228 attribute_hidden;
229
230/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
231 wake-up when the clone terminates. The memory location contains the
232 thread ID while the clone is running and is reset to zero by the kernel
233 afterwards. The kernel up to version 3.16.3 does not use the private futex
234 operations for futex wake-up when the clone terminates.
235 If ABSTIME is not NULL, is used a timeout for futex call. If the timeout
236 occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL.
237 The futex operation are issues with cancellable versions. */
238#define lll_wait_tid(tid, abstime) \
239 ({ \
240 int __res = 0; \
241 __typeof (tid) __tid; \
242 if (abstime != NULL) \
243 __res = __lll_timedwait_tid (&(tid), (abstime)); \
244 else \
245 /* We need acquire MO here so that we synchronize with the \
246 kernel's store to 0 when the clone terminates. (see above) */ \
247 while ((__tid = atomic_load_acquire (&(tid))) != 0) \
248 lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \
249 __res; \
250 })
251
252extern int __lll_lock_elision (int *futex, short *adapt_count, int private)
253 attribute_hidden;
254
255extern int __lll_unlock_elision (int *lock, int private)
256 attribute_hidden;
257
258extern int __lll_trylock_elision (int *lock, short *adapt_count)
259 attribute_hidden;
260
261#define lll_lock_elision(futex, adapt_count, private) \
262 __lll_lock_elision (&(futex), &(adapt_count), private)
263#define lll_unlock_elision(futex, adapt_count, private) \
264 __lll_unlock_elision (&(futex), private)
265#define lll_trylock_elision(futex, adapt_count) \
266 __lll_trylock_elision (&(futex), &(adapt_count))
267
268#endif /* !__ASSEMBLER__ */
269
270#endif /* lowlevellock.h */
libc/glibc/sysdeps/unix/sysv/linux/x86_64/sysdep.h created+434
...@@ -0,0 +1,434 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_X86_64_SYSDEP_H
19#define _LINUX_X86_64_SYSDEP_H 1
20
21/* Always enable vsyscalls on x86_64 */
22#define ALWAYS_USE_VSYSCALL 1
23
24/* There is some commonality. */
25#include <sysdeps/unix/sysv/linux/sysdep.h>
26#include <sysdeps/unix/x86_64/sysdep.h>
27#include <tls.h>
28
29/* Defines RTLD_PRIVATE_ERRNO. */
30#include <dl-sysdep.h>
31
32/* For Linux we can use the system call table in the header file
33 /usr/include/asm/unistd.h
34 of the kernel. But these symbols do not follow the SYS_* syntax
35 so we have to redefine the `SYS_ify' macro here. */
36#undef SYS_ify
37#define SYS_ify(syscall_name) __NR_##syscall_name
38
39/* This is a kludge to make syscalls.list find these under the names
40 pread and pwrite, since some kernel headers define those names
41 and some define the *64 names for the same system calls. */
42#if !defined __NR_pread && defined __NR_pread64
43# define __NR_pread __NR_pread64
44#endif
45#if !defined __NR_pwrite && defined __NR_pwrite64
46# define __NR_pwrite __NR_pwrite64
47#endif
48
49/* This is to help the old kernel headers where __NR_semtimedop is not
50 available. */
51#ifndef __NR_semtimedop
52# define __NR_semtimedop 220
53#endif
54
55
56#ifdef __ASSEMBLER__
57
58/* Linux uses a negative return value to indicate syscall errors,
59 unlike most Unices, which use the condition codes' carry flag.
60
61 Since version 2.1 the return value of a system call might be
62 negative even if the call succeeded. E.g., the `lseek' system call
63 might return a large offset. Therefore we must not anymore test
64 for < 0, but test for a real error by making sure the value in %eax
65 is a real error number. Linus said he will make sure the no syscall
66 returns a value in -1 .. -4095 as a valid result so we can savely
67 test with -4095. */
68
69/* We don't want the label for the error handle to be global when we define
70 it here. */
71# ifdef PIC
72# define SYSCALL_ERROR_LABEL 0f
73# else
74# define SYSCALL_ERROR_LABEL syscall_error
75# endif
76
77# undef PSEUDO
78# define PSEUDO(name, syscall_name, args) \
79 .text; \
80 ENTRY (name) \
81 DO_CALL (syscall_name, args); \
82 cmpq $-4095, %rax; \
83 jae SYSCALL_ERROR_LABEL
84
85# undef PSEUDO_END
86# define PSEUDO_END(name) \
87 SYSCALL_ERROR_HANDLER \
88 END (name)
89
90# undef PSEUDO_NOERRNO
91# define PSEUDO_NOERRNO(name, syscall_name, args) \
92 .text; \
93 ENTRY (name) \
94 DO_CALL (syscall_name, args)
95
96# undef PSEUDO_END_NOERRNO
97# define PSEUDO_END_NOERRNO(name) \
98 END (name)
99
100# define ret_NOERRNO ret
101
102# undef PSEUDO_ERRVAL
103# define PSEUDO_ERRVAL(name, syscall_name, args) \
104 .text; \
105 ENTRY (name) \
106 DO_CALL (syscall_name, args); \
107 negq %rax
108
109# undef PSEUDO_END_ERRVAL
110# define PSEUDO_END_ERRVAL(name) \
111 END (name)
112
113# define ret_ERRVAL ret
114
115# if defined PIC && RTLD_PRIVATE_ERRNO
116# define SYSCALL_SET_ERRNO \
117 lea rtld_errno(%rip), %RCX_LP; \
118 neg %eax; \
119 movl %eax, (%rcx)
120# else
121# if IS_IN (libc)
122# define SYSCALL_ERROR_ERRNO __libc_errno
123# else
124# define SYSCALL_ERROR_ERRNO errno
125# endif
126# define SYSCALL_SET_ERRNO \
127 movq SYSCALL_ERROR_ERRNO@GOTTPOFF(%rip), %rcx;\
128 neg %eax; \
129 movl %eax, %fs:(%rcx);
130# endif
131
132# ifndef PIC
133# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
134# else
135# define SYSCALL_ERROR_HANDLER \
1360: \
137 SYSCALL_SET_ERRNO; \
138 or $-1, %RAX_LP; \
139 ret;
140# endif /* PIC */
141
142/* The Linux/x86-64 kernel expects the system call parameters in
143 registers according to the following table:
144
145 syscall number rax
146 arg 1 rdi
147 arg 2 rsi
148 arg 3 rdx
149 arg 4 r10
150 arg 5 r8
151 arg 6 r9
152
153 The Linux kernel uses and destroys internally these registers:
154 return address from
155 syscall rcx
156 eflags from syscall r11
157
158 Normal function call, including calls to the system call stub
159 functions in the libc, get the first six parameters passed in
160 registers and the seventh parameter and later on the stack. The
161 register use is as follows:
162
163 system call number in the DO_CALL macro
164 arg 1 rdi
165 arg 2 rsi
166 arg 3 rdx
167 arg 4 rcx
168 arg 5 r8
169 arg 6 r9
170
171 We have to take care that the stack is aligned to 16 bytes. When
172 called the stack is not aligned since the return address has just
173 been pushed.
174
175
176 Syscalls of more than 6 arguments are not supported. */
177
178# undef DO_CALL
179# define DO_CALL(syscall_name, args) \
180 DOARGS_##args \
181 movl $SYS_ify (syscall_name), %eax; \
182 syscall;
183
184# define DOARGS_0 /* nothing */
185# define DOARGS_1 /* nothing */
186# define DOARGS_2 /* nothing */
187# define DOARGS_3 /* nothing */
188# define DOARGS_4 movq %rcx, %r10;
189# define DOARGS_5 DOARGS_4
190# define DOARGS_6 DOARGS_5
191
192#else /* !__ASSEMBLER__ */
193/* Define a macro which expands inline into the wrapper code for a system
194 call. */
195# undef INLINE_SYSCALL
196# define INLINE_SYSCALL(name, nr, args...) \
197 ({ \
198 unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
199 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
200 { \
201 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
202 resultvar = (unsigned long int) -1; \
203 } \
204 (long int) resultvar; })
205
206/* Define a macro with explicit types for arguments, which expands inline
207 into the wrapper code for a system call. It should be used when size
208 of any argument > size of long int. */
209# undef INLINE_SYSCALL_TYPES
210# define INLINE_SYSCALL_TYPES(name, nr, args...) \
211 ({ \
212 unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
213 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
214 { \
215 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
216 resultvar = (unsigned long int) -1; \
217 } \
218 (long int) resultvar; })
219
220# undef INTERNAL_SYSCALL_DECL
221# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
222
223/* Registers clobbered by syscall. */
224# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
225
226/* Create a variable 'name' based on type 'X' to avoid explicit types.
227 This is mainly used set use 64-bits arguments in x32. */
228#define TYPEFY(X, name) __typeof__ ((X) - (X)) name
229/* Explicit cast the argument to avoid integer from pointer warning on
230 x32. */
231#define ARGIFY(X) ((__typeof__ ((X) - (X))) (X))
232
233#undef INTERNAL_SYSCALL
234#define INTERNAL_SYSCALL(name, err, nr, args...) \
235 internal_syscall##nr (SYS_ify (name), err, args)
236
237#undef INTERNAL_SYSCALL_NCS
238#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
239 internal_syscall##nr (number, err, args)
240
241#undef internal_syscall0
242#define internal_syscall0(number, err, dummy...) \
243({ \
244 unsigned long int resultvar; \
245 asm volatile ( \
246 "syscall\n\t" \
247 : "=a" (resultvar) \
248 : "0" (number) \
249 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
250 (long int) resultvar; \
251})
252
253#undef internal_syscall1
254#define internal_syscall1(number, err, arg1) \
255({ \
256 unsigned long int resultvar; \
257 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
258 register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
259 asm volatile ( \
260 "syscall\n\t" \
261 : "=a" (resultvar) \
262 : "0" (number), "r" (_a1) \
263 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
264 (long int) resultvar; \
265})
266
267#undef internal_syscall2
268#define internal_syscall2(number, err, arg1, arg2) \
269({ \
270 unsigned long int resultvar; \
271 TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
272 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
273 register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
274 register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
275 asm volatile ( \
276 "syscall\n\t" \
277 : "=a" (resultvar) \
278 : "0" (number), "r" (_a1), "r" (_a2) \
279 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
280 (long int) resultvar; \
281})
282
283#undef internal_syscall3
284#define internal_syscall3(number, err, arg1, arg2, arg3) \
285({ \
286 unsigned long int resultvar; \
287 TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
288 TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
289 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
290 register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
291 register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
292 register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
293 asm volatile ( \
294 "syscall\n\t" \
295 : "=a" (resultvar) \
296 : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3) \
297 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
298 (long int) resultvar; \
299})
300
301#undef internal_syscall4
302#define internal_syscall4(number, err, arg1, arg2, arg3, arg4) \
303({ \
304 unsigned long int resultvar; \
305 TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
306 TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
307 TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
308 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
309 register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
310 register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
311 register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
312 register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
313 asm volatile ( \
314 "syscall\n\t" \
315 : "=a" (resultvar) \
316 : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4) \
317 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
318 (long int) resultvar; \
319})
320
321#undef internal_syscall5
322#define internal_syscall5(number, err, arg1, arg2, arg3, arg4, arg5) \
323({ \
324 unsigned long int resultvar; \
325 TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
326 TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
327 TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
328 TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
329 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
330 register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \
331 register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
332 register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
333 register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
334 register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
335 asm volatile ( \
336 "syscall\n\t" \
337 : "=a" (resultvar) \
338 : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
339 "r" (_a5) \
340 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
341 (long int) resultvar; \
342})
343
344#undef internal_syscall6
345#define internal_syscall6(number, err, arg1, arg2, arg3, arg4, arg5, arg6) \
346({ \
347 unsigned long int resultvar; \
348 TYPEFY (arg6, __arg6) = ARGIFY (arg6); \
349 TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
350 TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
351 TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
352 TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
353 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
354 register TYPEFY (arg6, _a6) asm ("r9") = __arg6; \
355 register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \
356 register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
357 register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
358 register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
359 register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
360 asm volatile ( \
361 "syscall\n\t" \
362 : "=a" (resultvar) \
363 : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
364 "r" (_a5), "r" (_a6) \
365 : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
366 (long int) resultvar; \
367})
368
369# undef INTERNAL_SYSCALL_ERROR_P
370# define INTERNAL_SYSCALL_ERROR_P(val, err) \
371 ((unsigned long int) (long int) (val) >= -4095L)
372
373# undef INTERNAL_SYSCALL_ERRNO
374# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
375
376/* List of system calls which are supported as vsyscalls. */
377# define HAVE_CLOCK_GETTIME_VSYSCALL 1
378# define HAVE_GETTIMEOFDAY_VSYSCALL 1
379# define HAVE_GETCPU_VSYSCALL 1
380
381# define SINGLE_THREAD_BY_GLOBAL 1
382
383#endif /* __ASSEMBLER__ */
384
385
386/* Pointer mangling support. */
387#if IS_IN (rtld)
388/* We cannot use the thread descriptor because in ld.so we use setjmp
389 earlier than the descriptor is initialized. */
390# ifdef __ASSEMBLER__
391# define PTR_MANGLE(reg) xor __pointer_chk_guard_local(%rip), reg; \
392 rol $2*LP_SIZE+1, reg
393# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
394 xor __pointer_chk_guard_local(%rip), reg
395# else
396# define PTR_MANGLE(reg) asm ("xor __pointer_chk_guard_local(%%rip), %0\n" \
397 "rol $2*" LP_SIZE "+1, %0" \
398 : "=r" (reg) : "0" (reg))
399# define PTR_DEMANGLE(reg) asm ("ror $2*" LP_SIZE "+1, %0\n" \
400 "xor __pointer_chk_guard_local(%%rip), %0" \
401 : "=r" (reg) : "0" (reg))
402# endif
403#else
404# ifdef __ASSEMBLER__
405# define PTR_MANGLE(reg) xor %fs:POINTER_GUARD, reg; \
406 rol $2*LP_SIZE+1, reg
407# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
408 xor %fs:POINTER_GUARD, reg
409# else
410# define PTR_MANGLE(var) asm ("xor %%fs:%c2, %0\n" \
411 "rol $2*" LP_SIZE "+1, %0" \
412 : "=r" (var) \
413 : "0" (var), \
414 "i" (offsetof (tcbhead_t, \
415 pointer_guard)))
416# define PTR_DEMANGLE(var) asm ("ror $2*" LP_SIZE "+1, %0\n" \
417 "xor %%fs:%c2, %0" \
418 : "=r" (var) \
419 : "0" (var), \
420 "i" (offsetof (tcbhead_t, \
421 pointer_guard)))
422# endif
423#endif
424
425/* How to pass the off{64}_t argument on p{readv,writev}{64}. */
426#undef LO_HI_LONG
427#define LO_HI_LONG(val) (val), 0
428
429/* Each shadow stack slot takes 8 bytes. Assuming that each stack
430 frame takes 256 bytes, this is used to compute shadow stack size
431 from stack size. */
432#define STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT 5
433
434#endif /* linux/x86_64/sysdep.h */
libc/glibc/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 2012-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_X32_SYSDEP_H
19#define _LINUX_X32_SYSDEP_H 1
20
21/* There is some commonality. */
22#include <sysdeps/unix/sysv/linux/x86_64/sysdep.h>
23#include <sysdeps/x86_64/x32/sysdep.h>
24
25/* How to pass the off{64}_t argument on p{readv,writev}{64}. */
26#undef LO_HI_LONG
27#define LO_HI_LONG(val) (val)
28
29#endif /* linux/x86_64/x32/sysdep.h */
libc/glibc/sysdeps/unix/x86_64/sysdep.h created+34
...@@ -0,0 +1,34 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <sysdeps/unix/sysdep.h>
19#include <sysdeps/x86_64/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* This is defined as a separate macro so that other sysdep.h files
24 can include this one and then redefine DO_CALL. */
25
26#define DO_CALL(syscall_name, args) \
27 lea SYS_ify (syscall_name), %rax; \
28 syscall
29
30#define r0 %rax /* Normal return-value register. */
31#define r1 %rbx /* Secondary return-value register. */
32#define MOVE(x,y) movq x, y
33
34#endif /* __ASSEMBLER__ */
libc/glibc/sysdeps/x86/bits/floatn.h deleted-121
...@@ -1,121 +0,0 @@
1/* Macros to control TS 18661-3 glibc features on x86.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_FLOATN_H
20#define _BITS_FLOATN_H
21
22#include <features.h>
23
24/* Defined to 1 if the current compiler invocation provides a
25 floating-point type with the IEEE 754 binary128 format, and this
26 glibc includes corresponding *f128 interfaces for it. The required
27 libgcc support was added some time after the basic compiler
28 support, for x86_64 and x86. */
29#if (defined __x86_64__ \
30 ? __GNUC_PREREQ (4, 3) \
31 : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
32# define __HAVE_FLOAT128 1
33#else
34# define __HAVE_FLOAT128 0
35#endif
36
37/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
38 from the default float, double and long double types in this glibc. */
39#if __HAVE_FLOAT128
40# define __HAVE_DISTINCT_FLOAT128 1
41#else
42# define __HAVE_DISTINCT_FLOAT128 0
43#endif
44
45/* Defined to 1 if the current compiler invocation provides a
46 floating-point type with the right format for _Float64x, and this
47 glibc includes corresponding *f64x interfaces for it. */
48#define __HAVE_FLOAT64X 1
49
50/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
51 of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
52 the format of _Float128, which must be different from that of long
53 double. */
54#define __HAVE_FLOAT64X_LONG_DOUBLE 1
55
56#ifndef __ASSEMBLER__
57
58/* Defined to concatenate the literal suffix to be used with _Float128
59 types, if __HAVE_FLOAT128 is 1. */
60# if __HAVE_FLOAT128
61# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
62/* The literal suffix f128 exists only since GCC 7.0. */
63# define __f128(x) x##q
64# else
65# define __f128(x) x##f128
66# endif
67# endif
68
69/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
70# if __HAVE_FLOAT128
71# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
72/* Add a typedef for older GCC compilers which don't natively support
73 _Complex _Float128. */
74typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
75# define __CFLOAT128 __cfloat128
76# else
77# define __CFLOAT128 _Complex _Float128
78# endif
79# endif
80
81/* The remaining of this file provides support for older compilers. */
82# if __HAVE_FLOAT128
83
84/* The type _Float128 exists only since GCC 7.0. */
85# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
86typedef __float128 _Float128;
87# endif
88
89/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */
90# if !__GNUC_PREREQ (7, 0)
91# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
92# endif
93
94/* Older GCC has only a subset of built-in functions for _Float128 on
95 x86, and __builtin_infq is not usable in static initializers.
96 Converting a narrower sNaN to _Float128 produces a quiet NaN, so
97 attempts to use _Float128 sNaNs will not work properly with older
98 compilers. */
99# if !__GNUC_PREREQ (7, 0)
100# define __builtin_copysignf128 __builtin_copysignq
101# define __builtin_fabsf128 __builtin_fabsq
102# define __builtin_inff128() ((_Float128) __builtin_inf ())
103# define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))
104# define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
105# endif
106
107/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
108 e.g.: __builtin_signbitf128, before GCC 6. However, there has never
109 been a __builtin_signbitf128 in GCC and the type-generic builtin is
110 only available since GCC 6. */
111# if !__GNUC_PREREQ (6, 0)
112# define __builtin_signbitf128 __signbitf128
113# endif
114
115# endif
116
117#endif /* !__ASSEMBLER__. */
118
119#include <bits/floatn-common.h>
120
121#endif /* _BITS_FLOATN_H */
libc/glibc/sysdeps/x86/bits/setjmp.h deleted-40
...@@ -1,40 +0,0 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Define the machine-dependent type `jmp_buf'. x86-64 version. */
19#ifndef _BITS_SETJMP_H
20#define _BITS_SETJMP_H 1
21
22#if !defined _SETJMP_H && !defined _PTHREAD_H
23# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
24#endif
25
26#include <bits/wordsize.h>
27
28#ifndef _ASM
29
30# if __WORDSIZE == 64
31typedef long int __jmp_buf[8];
32# elif defined __x86_64__
33__extension__ typedef long long int __jmp_buf[8];
34# else
35typedef int __jmp_buf[6];
36# endif
37
38#endif
39
40#endif /* bits/setjmp.h */
libc/glibc/sysdeps/x86_64/stackinfo.h deleted-43
...@@ -1,43 +0,0 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* This file contains a bit of information about the stack allocation
19 of the processor. */
20
21#ifndef _STACKINFO_H
22#define _STACKINFO_H 1
23
24#include <elf.h>
25
26/* On x86_64 the stack grows down. */
27#define _STACK_GROWS_DOWN 1
28
29/* Default to an executable stack. PF_X can be overridden if PT_GNU_STACK is
30 * present, but it is presumed absent. */
31#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
32
33/* Access to the stack pointer. The macros are used in alloca_account
34 for which they need to act as barriers as well, hence the additional
35 (unnecessary) parameters. */
36#define stackinfo_get_sp() \
37 ({ void *p__; asm volatile ("mov %%" RSP_LP ", %0" : "=r" (p__)); p__; })
38#define stackinfo_sub_sp(ptr) \
39 ({ ptrdiff_t d__; \
40 asm volatile ("sub %%" RSP_LP " , %0" : "=r" (d__) : "0" (ptr)); \
41 d__; })
42
43#endif /* stackinfo.h */
libc/glibc/sysdeps/x86_64/x32/symbol-hacks.h created+1
...@@ -0,0 +1 @@
1#include <sysdeps/generic/symbol-hacks.h>
libc/glibc/sysdeps/x86_64/x32/sysdep.h created+92
...@@ -0,0 +1,92 @@
1/* Assembler macros for x32.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <sysdeps/x86_64/sysdep.h>
20
21#undef LP_SIZE
22#undef LP_OP
23#undef ASM_ADDR
24
25#undef RAX_LP
26#undef RBP_LP
27#undef RBX_LP
28#undef RCX_LP
29#undef RDI_LP
30#undef RDX_LP
31#undef RSP_LP
32#undef RSI_LP
33#undef R8_LP
34#undef R9_LP
35#undef R10_LP
36#undef R11_LP
37#undef R12_LP
38#undef R13_LP
39#undef R14_LP
40#undef R15_LP
41
42#ifdef __ASSEMBLER__
43
44# define LP_SIZE 4
45
46# define LP_OP(insn) insn##l
47
48# define ASM_ADDR .long
49
50# define RAX_LP eax
51# define RBP_LP ebp
52# define RBX_LP ebx
53# define RCX_LP ecx
54# define RDI_LP edi
55# define RDX_LP edx
56# define RSI_LP esi
57# define RSP_LP esp
58# define R8_LP r8d
59# define R9_LP r9d
60# define R10_LP r10d
61# define R11_LP r11d
62# define R12_LP r12d
63# define R13_LP r13d
64# define R14_LP r14d
65# define R15_LP r15d
66
67#else /* __ASSEMBLER__ */
68
69# define LP_SIZE "4"
70
71# define LP_OP(insn) #insn "l"
72
73# define ASM_ADDR ".long"
74
75# define RAX_LP "eax"
76# define RBP_LP "ebp"
77# define RBX_LP "ebx"
78# define RCX_LP "ecx"
79# define RDI_LP "edi"
80# define RDX_LP "edx"
81# define RSI_LP "esi"
82# define RSP_LP "esp"
83# define R8_LP "r8d"
84# define R9_LP "r9d"
85# define R10_LP "r10d"
86# define R11_LP "r11d"
87# define R12_LP "r12d"
88# define R13_LP "r13d"
89# define R14_LP "r14d"
90# define R15_LP "r15d"
91
92#endif /* __ASSEMBLER__ */
libc/glibc/time/sys/time.h deleted-188
...@@ -1,188 +0,0 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIME_H
19#define _SYS_TIME_H 1
20
21#include <features.h>
22
23#include <bits/types.h>
24#include <bits/types/time_t.h>
25#include <bits/types/struct_timeval.h>
26
27#ifndef __suseconds_t_defined
28typedef __suseconds_t suseconds_t;
29# define __suseconds_t_defined
30#endif
31
32#include <sys/select.h>
33
34__BEGIN_DECLS
35
36#ifdef __USE_GNU
37/* Macros for converting between `struct timeval' and `struct timespec'. */
38# define TIMEVAL_TO_TIMESPEC(tv, ts) { \
39 (ts)->tv_sec = (tv)->tv_sec; \
40 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
41}
42# define TIMESPEC_TO_TIMEVAL(tv, ts) { \
43 (tv)->tv_sec = (ts)->tv_sec; \
44 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
45}
46#endif
47
48
49#ifdef __USE_MISC
50/* Structure crudely representing a timezone.
51 This is obsolete and should never be used. */
52struct timezone
53 {
54 int tz_minuteswest; /* Minutes west of GMT. */
55 int tz_dsttime; /* Nonzero if DST is ever in effect. */
56 };
57
58typedef struct timezone *__restrict __timezone_ptr_t;
59#else
60typedef void *__restrict __timezone_ptr_t;
61#endif
62
63/* Get the current time of day and timezone information,
64 putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
65 Returns 0 on success, -1 on errors.
66 NOTE: This form of timezone information is obsolete.
67 Use the functions and variables declared in <time.h> instead. */
68extern int gettimeofday (struct timeval *__restrict __tv,
69 __timezone_ptr_t __tz) __THROW __nonnull ((1));
70
71#ifdef __USE_MISC
72/* Set the current time of day and timezone information.
73 This call is restricted to the super-user. */
74extern int settimeofday (const struct timeval *__tv,
75 const struct timezone *__tz)
76 __THROW;
77
78/* Adjust the current time of day by the amount in DELTA.
79 If OLDDELTA is not NULL, it is filled in with the amount
80 of time adjustment remaining to be done from the last `adjtime' call.
81 This call is restricted to the super-user. */
82extern int adjtime (const struct timeval *__delta,
83 struct timeval *__olddelta) __THROW;
84#endif
85
86
87/* Values for the first argument to `getitimer' and `setitimer'. */
88enum __itimer_which
89 {
90 /* Timers run in real time. */
91 ITIMER_REAL = 0,
92#define ITIMER_REAL ITIMER_REAL
93 /* Timers run only when the process is executing. */
94 ITIMER_VIRTUAL = 1,
95#define ITIMER_VIRTUAL ITIMER_VIRTUAL
96 /* Timers run when the process is executing and when
97 the system is executing on behalf of the process. */
98 ITIMER_PROF = 2
99#define ITIMER_PROF ITIMER_PROF
100 };
101
102/* Type of the second argument to `getitimer' and
103 the second and third arguments `setitimer'. */
104struct itimerval
105 {
106 /* Value to put into `it_value' when the timer expires. */
107 struct timeval it_interval;
108 /* Time to the next timer expiration. */
109 struct timeval it_value;
110 };
111
112#if defined __USE_GNU && !defined __cplusplus
113/* Use the nicer parameter type only in GNU mode and not for C++ since the
114 strict C++ rules prevent the automatic promotion. */
115typedef enum __itimer_which __itimer_which_t;
116#else
117typedef int __itimer_which_t;
118#endif
119
120/* Set *VALUE to the current setting of timer WHICH.
121 Return 0 on success, -1 on errors. */
122extern int getitimer (__itimer_which_t __which,
123 struct itimerval *__value) __THROW;
124
125/* Set the timer WHICH to *NEW. If OLD is not NULL,
126 set *OLD to the old value of timer WHICH.
127 Returns 0 on success, -1 on errors. */
128extern int setitimer (__itimer_which_t __which,
129 const struct itimerval *__restrict __new,
130 struct itimerval *__restrict __old) __THROW;
131
132/* Change the access time of FILE to TVP[0] and the modification time of
133 FILE to TVP[1]. If TVP is a null pointer, use the current time instead.
134 Returns 0 on success, -1 on errors. */
135extern int utimes (const char *__file, const struct timeval __tvp[2])
136 __THROW __nonnull ((1));
137
138#ifdef __USE_MISC
139/* Same as `utimes', but does not follow symbolic links. */
140extern int lutimes (const char *__file, const struct timeval __tvp[2])
141 __THROW __nonnull ((1));
142
143/* Same as `utimes', but takes an open file descriptor instead of a name. */
144extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW;
145#endif
146
147#ifdef __USE_GNU
148/* Change the access time of FILE relative to FD to TVP[0] and the
149 modification time of FILE to TVP[1]. If TVP is a null pointer, use
150 the current time instead. Returns 0 on success, -1 on errors. */
151extern int futimesat (int __fd, const char *__file,
152 const struct timeval __tvp[2]) __THROW;
153#endif
154
155
156#ifdef __USE_MISC
157/* Convenience macros for operations on timevals.
158 NOTE: `timercmp' does not work for >= or <=. */
159# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
160# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
161# define timercmp(a, b, CMP) \
162 (((a)->tv_sec == (b)->tv_sec) ? \
163 ((a)->tv_usec CMP (b)->tv_usec) : \
164 ((a)->tv_sec CMP (b)->tv_sec))
165# define timeradd(a, b, result) \
166 do { \
167 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
168 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
169 if ((result)->tv_usec >= 1000000) \
170 { \
171 ++(result)->tv_sec; \
172 (result)->tv_usec -= 1000000; \
173 } \
174 } while (0)
175# define timersub(a, b, result) \
176 do { \
177 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
178 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
179 if ((result)->tv_usec < 0) { \
180 --(result)->tv_sec; \
181 (result)->tv_usec += 1000000; \
182 } \
183 } while (0)
184#endif /* Misc. */
185
186__END_DECLS
187
188#endif /* sys/time.h */
libc/glibc/time/time.h deleted-309
...@@ -1,309 +0,0 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.23 Date and time <time.h>
20 */
21
22#ifndef _TIME_H
23#define _TIME_H 1
24
25#include <features.h>
26
27#define __need_size_t
28#define __need_NULL
29#include <stddef.h>
30
31/* This defines CLOCKS_PER_SEC, which is the number of processor clock
32 ticks per second, and possibly a number of other constants. */
33#include <bits/time.h>
34
35/* Many of the typedefs and structs whose official home is this header
36 may also need to be defined by other headers. */
37#include <bits/types/clock_t.h>
38#include <bits/types/time_t.h>
39#include <bits/types/struct_tm.h>
40
41#if defined __USE_POSIX199309 || defined __USE_ISOC11
42# include <bits/types/struct_timespec.h>
43#endif
44
45#ifdef __USE_POSIX199309
46# include <bits/types/clockid_t.h>
47# include <bits/types/timer_t.h>
48# include <bits/types/struct_itimerspec.h>
49struct sigevent;
50#endif
51
52#ifdef __USE_XOPEN2K
53# ifndef __pid_t_defined
54typedef __pid_t pid_t;
55# define __pid_t_defined
56# endif
57#endif
58
59#ifdef __USE_XOPEN2K8
60# include <bits/types/locale_t.h>
61#endif
62
63#ifdef __USE_ISOC11
64/* Time base values for timespec_get. */
65# define TIME_UTC 1
66#endif
67
68__BEGIN_DECLS
69
70/* Time used by the program so far (user time + system time).
71 The result / CLOCKS_PER_SEC is program time in seconds. */
72extern clock_t clock (void) __THROW;
73
74/* Return the current time and put it in *TIMER if TIMER is not NULL. */
75extern time_t time (time_t *__timer) __THROW;
76
77/* Return the difference between TIME1 and TIME0. */
78extern double difftime (time_t __time1, time_t __time0)
79 __THROW __attribute__ ((__const__));
80
81/* Return the `time_t' representation of TP and normalize TP. */
82extern time_t mktime (struct tm *__tp) __THROW;
83
84
85/* Format TP into S according to FORMAT.
86 Write no more than MAXSIZE characters and return the number
87 of characters written, or 0 if it would exceed MAXSIZE. */
88extern size_t strftime (char *__restrict __s, size_t __maxsize,
89 const char *__restrict __format,
90 const struct tm *__restrict __tp) __THROW;
91
92#ifdef __USE_XOPEN
93/* Parse S according to FORMAT and store binary time information in TP.
94 The return value is a pointer to the first unparsed character in S. */
95extern char *strptime (const char *__restrict __s,
96 const char *__restrict __fmt, struct tm *__tp)
97 __THROW;
98#endif
99
100#ifdef __USE_XOPEN2K8
101/* Similar to the two functions above but take the information from
102 the provided locale and not the global locale. */
103
104extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
105 const char *__restrict __format,
106 const struct tm *__restrict __tp,
107 locale_t __loc) __THROW;
108#endif
109
110#ifdef __USE_GNU
111extern char *strptime_l (const char *__restrict __s,
112 const char *__restrict __fmt, struct tm *__tp,
113 locale_t __loc) __THROW;
114#endif
115
116
117/* Return the `struct tm' representation of *TIMER
118 in Universal Coordinated Time (aka Greenwich Mean Time). */
119extern struct tm *gmtime (const time_t *__timer) __THROW;
120
121/* Return the `struct tm' representation
122 of *TIMER in the local timezone. */
123extern struct tm *localtime (const time_t *__timer) __THROW;
124
125#ifdef __USE_POSIX
126/* Return the `struct tm' representation of *TIMER in UTC,
127 using *TP to store the result. */
128extern struct tm *gmtime_r (const time_t *__restrict __timer,
129 struct tm *__restrict __tp) __THROW;
130
131/* Return the `struct tm' representation of *TIMER in local time,
132 using *TP to store the result. */
133extern struct tm *localtime_r (const time_t *__restrict __timer,
134 struct tm *__restrict __tp) __THROW;
135#endif /* POSIX */
136
137/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
138 that is the representation of TP in this format. */
139extern char *asctime (const struct tm *__tp) __THROW;
140
141/* Equivalent to `asctime (localtime (timer))'. */
142extern char *ctime (const time_t *__timer) __THROW;
143
144#ifdef __USE_POSIX
145/* Reentrant versions of the above functions. */
146
147/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
148 that is the representation of TP in this format. */
149extern char *asctime_r (const struct tm *__restrict __tp,
150 char *__restrict __buf) __THROW;
151
152/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */
153extern char *ctime_r (const time_t *__restrict __timer,
154 char *__restrict __buf) __THROW;
155#endif /* POSIX */
156
157
158/* Defined in localtime.c. */
159extern char *__tzname[2]; /* Current timezone names. */
160extern int __daylight; /* If daylight-saving time is ever in use. */
161extern long int __timezone; /* Seconds west of UTC. */
162
163
164#ifdef __USE_POSIX
165/* Same as above. */
166extern char *tzname[2];
167
168/* Set time conversion information from the TZ environment variable.
169 If TZ is not defined, a locale-dependent default is used. */
170extern void tzset (void) __THROW;
171#endif
172
173#if defined __USE_MISC || defined __USE_XOPEN
174extern int daylight;
175extern long int timezone;
176#endif
177
178#ifdef __USE_MISC
179/* Set the system time to *WHEN.
180 This call is restricted to the superuser. */
181extern int stime (const time_t *__when) __THROW;
182#endif
183
184
185/* Nonzero if YEAR is a leap year (every 4 years,
186 except every 100th isn't, and every 400th is). */
187#define __isleap(year) \
188 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
189
190
191#ifdef __USE_MISC
192/* Miscellaneous functions many Unices inherited from the public domain
193 localtime package. These are included only for compatibility. */
194
195/* Like `mktime', but for TP represents Universal Time, not local time. */
196extern time_t timegm (struct tm *__tp) __THROW;
197
198/* Another name for `mktime'. */
199extern time_t timelocal (struct tm *__tp) __THROW;
200
201/* Return the number of days in YEAR. */
202extern int dysize (int __year) __THROW __attribute__ ((__const__));
203#endif
204
205
206#ifdef __USE_POSIX199309
207/* Pause execution for a number of nanoseconds.
208
209 This function is a cancellation point and therefore not marked with
210 __THROW. */
211extern int nanosleep (const struct timespec *__requested_time,
212 struct timespec *__remaining);
213
214
215/* Get resolution of clock CLOCK_ID. */
216extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
217
218/* Get current value of clock CLOCK_ID and store it in TP. */
219extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
220
221/* Set clock CLOCK_ID to value TP. */
222extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
223 __THROW;
224
225# ifdef __USE_XOPEN2K
226/* High-resolution sleep with the specified clock.
227
228 This function is a cancellation point and therefore not marked with
229 __THROW. */
230extern int clock_nanosleep (clockid_t __clock_id, int __flags,
231 const struct timespec *__req,
232 struct timespec *__rem);
233
234/* Return clock ID for CPU-time clock. */
235extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
236# endif
237
238
239/* Create new per-process timer using CLOCK_ID. */
240extern int timer_create (clockid_t __clock_id,
241 struct sigevent *__restrict __evp,
242 timer_t *__restrict __timerid) __THROW;
243
244/* Delete timer TIMERID. */
245extern int timer_delete (timer_t __timerid) __THROW;
246
247/* Set timer TIMERID to VALUE, returning old value in OVALUE. */
248extern int timer_settime (timer_t __timerid, int __flags,
249 const struct itimerspec *__restrict __value,
250 struct itimerspec *__restrict __ovalue) __THROW;
251
252/* Get current value of timer TIMERID and store it in VALUE. */
253extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
254 __THROW;
255
256/* Get expiration overrun for timer TIMERID. */
257extern int timer_getoverrun (timer_t __timerid) __THROW;
258#endif
259
260
261#ifdef __USE_ISOC11
262/* Set TS to calendar time based in time base BASE. */
263extern int timespec_get (struct timespec *__ts, int __base)
264 __THROW __nonnull ((1));
265#endif
266
267
268#ifdef __USE_XOPEN_EXTENDED
269/* Set to one of the following values to indicate an error.
270 1 the DATEMSK environment variable is null or undefined,
271 2 the template file cannot be opened for reading,
272 3 failed to get file status information,
273 4 the template file is not a regular file,
274 5 an error is encountered while reading the template file,
275 6 memory allication failed (not enough memory available),
276 7 there is no line in the template that matches the input,
277 8 invalid input specification Example: February 31 or a time is
278 specified that can not be represented in a time_t (representing
279 the time in seconds since 00:00:00 UTC, January 1, 1970) */
280extern int getdate_err;
281
282/* Parse the given string as a date specification and return a value
283 representing the value. The templates from the file identified by
284 the environment variable DATEMSK are used. In case of an error
285 `getdate_err' is set.
286
287 This function is a possible cancellation point and therefore not
288 marked with __THROW. */
289extern struct tm *getdate (const char *__string);
290#endif
291
292#ifdef __USE_GNU
293/* Since `getdate' is not reentrant because of the use of `getdate_err'
294 and the static buffer to return the result in, we provide a thread-safe
295 variant. The functionality is the same. The result is returned in
296 the buffer pointed to by RESBUFP and in case of an error the return
297 value is != 0 with the same values as given above for `getdate_err'.
298
299 This function is not part of POSIX and therefore no official
300 cancellation point. But due to similarity with an POSIX interface
301 or due to the implementation it is a cancellation point and
302 therefore not marked with __THROW. */
303extern int getdate_r (const char *__restrict __string,
304 struct tm *__restrict __resbufp);
305#endif
306
307__END_DECLS
308
309#endif /* time.h. */
src/link.cpp+145-49
...@@ -153,15 +153,147 @@ static const char *build_libunwind(CodeGen *parent) {...@@ -153,15 +153,147 @@ static const char *build_libunwind(CodeGen *parent) {
153 return buf_ptr(&child_gen->output_file_path);153 return buf_ptr(&child_gen->output_file_path);
154}154}
155155
156static void glibc_add_include_dirs_arch(CFile *c_file, ZigLLVM_ArchType arch, const char *nptl, const char *dir) {
157 bool is_x86 = arch == ZigLLVM_x86 || arch == ZigLLVM_x86_64;
158 bool is_aarch64 = arch == ZigLLVM_aarch64 || arch == ZigLLVM_aarch64_be;
159 bool is_mips = arch == ZigLLVM_mips || arch == ZigLLVM_mipsel ||
160 arch == ZigLLVM_mips64el || arch == ZigLLVM_mips64;
161 bool is_arm = arch == ZigLLVM_arm || arch == ZigLLVM_armeb;
162 bool is_ppc = arch == ZigLLVM_ppc || arch == ZigLLVM_ppc64 || arch == ZigLLVM_ppc64le;
163 bool is_riscv = arch == ZigLLVM_riscv32 || arch == ZigLLVM_riscv64;
164 bool is_64 = target_arch_pointer_bit_width(arch) == 64;
165
166 if (is_x86) {
167 if (arch == ZigLLVM_x86_64) {
168 if (nptl != nullptr) {
169 c_file->args.append("-I");
170 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "x86_64" OS_SEP "%s", dir, nptl)));
171 } else {
172 c_file->args.append("-I");
173 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "x86_64", dir)));
174 }
175 }
176 if (nptl != nullptr) {
177 c_file->args.append("-I");
178 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "x86" OS_SEP "%s", dir, nptl)));
179 } else {
180 c_file->args.append("-I");
181 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "x86", dir)));
182 }
183 } else if (is_arm) {
184 if (nptl != nullptr) {
185 c_file->args.append("-I");
186 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "arm" OS_SEP "%s", dir, nptl)));
187 } else {
188 c_file->args.append("-I");
189 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "arm", dir)));
190 }
191 } else if (is_mips) {
192 if (nptl != nullptr) {
193 c_file->args.append("-I");
194 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "mips" OS_SEP "%s", dir, nptl)));
195 } else {
196 if (is_64) {
197 c_file->args.append("-I");
198 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "mips64", dir)));
199 } else {
200 c_file->args.append("-I");
201 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "mips32", dir)));
202 }
203 c_file->args.append("-I");
204 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "mips", dir)));
205 }
206 } else if (is_aarch64) {
207 if (nptl != nullptr) {
208 c_file->args.append("-I");
209 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "aarch64" OS_SEP "%s", dir, nptl)));
210 } else {
211 c_file->args.append("-I");
212 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "aarch64", dir)));
213 }
214 } else if (is_ppc) {
215 if (nptl != nullptr) {
216 c_file->args.append("-I");
217 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "powerpc" OS_SEP "%s", dir, nptl)));
218 } else {
219 if (is_64) {
220 c_file->args.append("-I");
221 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "powerpc64", dir)));
222 } else {
223 c_file->args.append("-I");
224 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "powerpc32", dir)));
225 }
226 c_file->args.append("-I");
227 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "powerpc", dir)));
228 }
229 } else if (is_riscv) {
230 if (nptl != nullptr) {
231 c_file->args.append("-I");
232 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "riscv" OS_SEP "%s", dir, nptl)));
233 } else {
234 c_file->args.append("-I");
235 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "riscv", dir)));
236 }
237 }
238}
239
240static void glibc_add_include_dirs(CodeGen *parent, CFile *c_file) {
241 ZigLLVM_ArchType arch = parent->zig_target->arch;
242 const char *nptl = (parent->zig_target->os == OsLinux) ? "nptl" : "htl";
243 const char *glibc = path_from_libc(parent, "glibc");
244
245 c_file->args.append("-I");
246 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "include", glibc)));
247
248 if (parent->zig_target->os == OsLinux) {
249 glibc_add_include_dirs_arch(c_file, arch, nullptr,
250 path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "unix" OS_SEP "sysv" OS_SEP "linux"));
251 }
252
253 if (nptl != nullptr) {
254 glibc_add_include_dirs_arch(c_file, arch, nptl, path_from_libc(parent, "glibc" OS_SEP "sysdeps"));
255 }
256
257 if (parent->zig_target->os == OsLinux) {
258 c_file->args.append("-I");
259 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
260 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "include"));
261 c_file->args.append("-I");
262 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
263 "unix" OS_SEP "sysv" OS_SEP "linux"));
264 }
265 if (nptl != nullptr) {
266 c_file->args.append("-I");
267 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "sysdeps" OS_SEP "%s", glibc, nptl)));
268 }
269
270 c_file->args.append("-I");
271 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "pthread"));
272
273 c_file->args.append("-I");
274 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "unix" OS_SEP "sysv"));
275
276 glibc_add_include_dirs_arch(c_file, arch, nullptr,
277 path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "unix"));
278
279 c_file->args.append("-I");
280 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "unix"));
281
282 glibc_add_include_dirs_arch(c_file, arch, nullptr, path_from_libc(parent, "glibc" OS_SEP "sysdeps"));
283
284 c_file->args.append("-I");
285 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
286
287 c_file->args.append("-I");
288 c_file->args.append(path_from_libc(parent, "glibc"));
289}
290
156static const char *get_libc_crt_file(CodeGen *parent, const char *file) {291static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
157 if (parent->libc == nullptr && target_is_glibc(parent)) {292 if (parent->libc == nullptr && target_is_glibc(parent)) {
158 if (strcmp(file, "crti.o") == 0) {293 if (strcmp(file, "crti.o") == 0) {
159 CFile *c_file = allocate<CFile>(1);294 CFile *c_file = allocate<CFile>(1);
160 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "crti.S");295 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "crti.S");
161 c_file->args.append("-I");296 glibc_add_include_dirs(parent, c_file);
162 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
163 c_file->args.append("-I");
164 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
165 c_file->args.append("-D_LIBC_REENTRANT");297 c_file->args.append("-D_LIBC_REENTRANT");
166 c_file->args.append("-include");298 c_file->args.append("-include");
167 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));299 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
...@@ -183,6 +315,7 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -183,6 +315,7 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
183 } else if (strcmp(file, "crtn.o") == 0) {315 } else if (strcmp(file, "crtn.o") == 0) {
184 CFile *c_file = allocate<CFile>(1);316 CFile *c_file = allocate<CFile>(1);
185 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "crtn.S");317 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "crtn.S");
318 glibc_add_include_dirs(parent, c_file);
186 c_file->args.append("-D_LIBC_REENTRANT");319 c_file->args.append("-D_LIBC_REENTRANT");
187 c_file->args.append("-DMODULE_NAME=libc");320 c_file->args.append("-DMODULE_NAME=libc");
188 c_file->args.append("-DTOP_NAMESPACE=glibc");321 c_file->args.append("-DTOP_NAMESPACE=glibc");
...@@ -193,14 +326,7 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -193,14 +326,7 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
193 } else if (strcmp(file, "start.os") == 0) {326 } else if (strcmp(file, "start.os") == 0) {
194 CFile *c_file = allocate<CFile>(1);327 CFile *c_file = allocate<CFile>(1);
195 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "start.S");328 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "start.S");
196 c_file->args.append("-I");329 glibc_add_include_dirs(parent, c_file);
197 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64"));
198 c_file->args.append("-I");
199 c_file->args.append(path_from_libc(parent, "glibc"));
200 c_file->args.append("-I");
201 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
202 c_file->args.append("-I");
203 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
204 c_file->args.append("-D_LIBC_REENTRANT");330 c_file->args.append("-D_LIBC_REENTRANT");
205 c_file->args.append("-include");331 c_file->args.append("-include");
206 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));332 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
...@@ -218,9 +344,8 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -218,9 +344,8 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
218 CFile *c_file = allocate<CFile>(1);344 CFile *c_file = allocate<CFile>(1);
219 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "abi-note.S");345 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "abi-note.S");
220 c_file->args.append("-I");346 c_file->args.append("-I");
221 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
222 c_file->args.append("-I");
223 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "csu"));347 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "csu"));
348 glibc_add_include_dirs(parent, c_file);
224 c_file->args.append("-D_LIBC_REENTRANT");349 c_file->args.append("-D_LIBC_REENTRANT");
225 c_file->args.append("-DMODULE_NAME=libc");350 c_file->args.append("-DMODULE_NAME=libc");
226 c_file->args.append("-DTOP_NAMESPACE=glibc");351 c_file->args.append("-DTOP_NAMESPACE=glibc");
...@@ -231,6 +356,9 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -231,6 +356,9 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
231 } else if (strcmp(file, "init.o") == 0) {356 } else if (strcmp(file, "init.o") == 0) {
232 CFile *c_file = allocate<CFile>(1);357 CFile *c_file = allocate<CFile>(1);
233 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "init.c");358 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "init.c");
359 c_file->args.append("-I");
360 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "csu"));
361 glibc_add_include_dirs(parent, c_file);
234 c_file->args.append("-std=gnu11");362 c_file->args.append("-std=gnu11");
235 c_file->args.append("-fgnu89-inline");363 c_file->args.append("-fgnu89-inline");
236 c_file->args.append("-g");364 c_file->args.append("-g");
...@@ -238,10 +366,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -238,10 +366,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
238 c_file->args.append("-fmerge-all-constants");366 c_file->args.append("-fmerge-all-constants");
239 c_file->args.append("-fno-stack-protector");367 c_file->args.append("-fno-stack-protector");
240 c_file->args.append("-fmath-errno");368 c_file->args.append("-fmath-errno");
241 c_file->args.append("-I");
242 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
243 c_file->args.append("-I");
244 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
245 c_file->args.append("-DSTACK_PROTECTOR_LEVEL=0");369 c_file->args.append("-DSTACK_PROTECTOR_LEVEL=0");
246 c_file->args.append("-ftls-model=initial-exec");370 c_file->args.append("-ftls-model=initial-exec");
247 c_file->args.append("-D_LIBC_REENTRANT");371 c_file->args.append("-D_LIBC_REENTRANT");
...@@ -289,9 +413,8 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -289,9 +413,8 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
289 c_file->args.append("-fmath-errno");413 c_file->args.append("-fmath-errno");
290 c_file->args.append("-fno-stack-protector");414 c_file->args.append("-fno-stack-protector");
291 c_file->args.append("-I");415 c_file->args.append("-I");
292 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));416 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "csu"));
293 c_file->args.append("-I");417 glibc_add_include_dirs(parent, c_file);
294 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
295 c_file->args.append("-DSTACK_PROTECTOR_LEVEL=0");418 c_file->args.append("-DSTACK_PROTECTOR_LEVEL=0");
296 c_file->args.append("-fPIC");419 c_file->args.append("-fPIC");
297 c_file->args.append("-fno-stack-protector");420 c_file->args.append("-fno-stack-protector");
...@@ -338,34 +461,7 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -338,34 +461,7 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
338 c_file->args.append("-fmath-errno");461 c_file->args.append("-fmath-errno");
339 c_file->args.append("-ftls-model=initial-exec");462 c_file->args.append("-ftls-model=initial-exec");
340 c_file->args.append("-Wno-ignored-attributes");463 c_file->args.append("-Wno-ignored-attributes");
341 c_file->args.append("-I");464 glibc_add_include_dirs(parent, c_file);
342 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
343 c_file->args.append("-I");
344 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
345 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "x86_64"));
346 c_file->args.append("-I");
347 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
348 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "x86"));
349 c_file->args.append("-I");
350 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86"));
351 c_file->args.append("-I");
352 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86" OS_SEP "nptl"));
353 c_file->args.append("-I");
354 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
355 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "include"));
356 c_file->args.append("-I");
357 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
358 "unix" OS_SEP "sysv" OS_SEP "linux"));
359 c_file->args.append("-I");
360 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "nptl"));
361 c_file->args.append("-I");
362 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "pthread"));
363 c_file->args.append("-I");
364 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64"));
365 c_file->args.append("-I");
366 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
367 c_file->args.append("-I");
368 c_file->args.append(path_from_libc(parent, "glibc"));
369 c_file->args.append("-D_LIBC_REENTRANT");465 c_file->args.append("-D_LIBC_REENTRANT");
370 c_file->args.append("-include");466 c_file->args.append("-include");
371 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));467 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
src/target.cpp+4-4
...@@ -721,7 +721,7 @@ ZigLLVM_ObjectFormatType target_object_format(const ZigTarget *target) {...@@ -721,7 +721,7 @@ ZigLLVM_ObjectFormatType target_object_format(const ZigTarget *target) {
721721
722// See lib/Support/Triple.cpp in LLVM for the source of this data.722// See lib/Support/Triple.cpp in LLVM for the source of this data.
723// getArchPointerBitWidth723// getArchPointerBitWidth
724static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) {724uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch) {
725 switch (arch) {725 switch (arch) {
726 case ZigLLVM_UnknownArch:726 case ZigLLVM_UnknownArch:
727 return 0;727 return 0;
...@@ -816,7 +816,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {...@@ -816,7 +816,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
816 return 32;816 return 32;
817 case CIntTypeLong:817 case CIntTypeLong:
818 case CIntTypeULong:818 case CIntTypeULong:
819 return get_arch_pointer_bit_width(target->arch);819 return target_arch_pointer_bit_width(target->arch);
820 case CIntTypeLongLong:820 case CIntTypeLongLong:
821 case CIntTypeULongLong:821 case CIntTypeULongLong:
822 return 64;822 return 64;
...@@ -839,7 +839,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {...@@ -839,7 +839,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
839 return 32;839 return 32;
840 case CIntTypeLong:840 case CIntTypeLong:
841 case CIntTypeULong:841 case CIntTypeULong:
842 return get_arch_pointer_bit_width(target->arch);842 return target_arch_pointer_bit_width(target->arch);
843 case CIntTypeLongLong:843 case CIntTypeLongLong:
844 case CIntTypeULongLong:844 case CIntTypeULongLong:
845 return 64;845 return 64;
...@@ -967,7 +967,7 @@ static FloatAbi get_float_abi(const ZigTarget *target) {...@@ -967,7 +967,7 @@ static FloatAbi get_float_abi(const ZigTarget *target) {
967}967}
968968
969static bool is_64_bit(ZigLLVM_ArchType arch) {969static bool is_64_bit(ZigLLVM_ArchType arch) {
970 return get_arch_pointer_bit_width(arch) == 64;970 return target_arch_pointer_bit_width(arch) == 64;
971}971}
972972
973const char *target_dynamic_linker(const ZigTarget *target) {973const char *target_dynamic_linker(const ZigTarget *target) {
src/target.hpp+2
...@@ -160,4 +160,6 @@ bool target_requires_libc(const ZigTarget *target);...@@ -160,4 +160,6 @@ bool target_requires_libc(const ZigTarget *target);
160bool target_supports_fpic(const ZigTarget *target);160bool target_supports_fpic(const ZigTarget *target);
161bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi);161bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi);
162162
163uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch);
164
163#endif165#endif