4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * Implementation of all external interfaces between ld.so.1 and libc.
28 *
29 * This file started as a set of routines that provided synchronization and
30 * locking operations using calls to libthread. libthread has merged with libc
31 * under the Unified Process Model (UPM), and things have gotten a lot simpler.
32 * This file continues to establish and redirect various events within ld.so.1
33 * to interfaces within libc.
34 *
35 * Until libc is loaded and relocated, any external interfaces are captured
36 * locally. Each link-map list maintains its own set of external vectors, as
37 * each link-map list typically provides its own libc. Although this per-link-
38 * map list vectoring provides a degree of flexibility, there is a protocol
39 * expected when calling various libc interfaces.
40 *
41 * i. Any new alternative link-map list should call CI_THRINIT, and then call
42 * CI_TLS_MODADD to register any TLS for each object of that link-map list
43 * (this item is labeled i. as auditors can be the first objects loaded,
650 va_list ap;
651
652 va_start(ap, oflag);
653 mode = va_arg(ap, mode_t);
654 va_end(ap);
655 return (__openat(fd, path, oflag, mode));
656 }
657
658 ssize_t
659 read(int fd, void *buf, size_t size)
660 {
661 extern ssize_t __read(int, void *, size_t);
662 return (__read(fd, buf, size));
663 }
664
665 ssize_t
666 write(int fd, const void *buf, size_t size)
667 {
668 extern ssize_t __write(int, const void *, size_t);
669 return (__write(fd, buf, size));
670 }
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 */
26
27 /*
28 * Implementation of all external interfaces between ld.so.1 and libc.
29 *
30 * This file started as a set of routines that provided synchronization and
31 * locking operations using calls to libthread. libthread has merged with libc
32 * under the Unified Process Model (UPM), and things have gotten a lot simpler.
33 * This file continues to establish and redirect various events within ld.so.1
34 * to interfaces within libc.
35 *
36 * Until libc is loaded and relocated, any external interfaces are captured
37 * locally. Each link-map list maintains its own set of external vectors, as
38 * each link-map list typically provides its own libc. Although this per-link-
39 * map list vectoring provides a degree of flexibility, there is a protocol
40 * expected when calling various libc interfaces.
41 *
42 * i. Any new alternative link-map list should call CI_THRINIT, and then call
43 * CI_TLS_MODADD to register any TLS for each object of that link-map list
44 * (this item is labeled i. as auditors can be the first objects loaded,
651 va_list ap;
652
653 va_start(ap, oflag);
654 mode = va_arg(ap, mode_t);
655 va_end(ap);
656 return (__openat(fd, path, oflag, mode));
657 }
658
659 ssize_t
660 read(int fd, void *buf, size_t size)
661 {
662 extern ssize_t __read(int, void *, size_t);
663 return (__read(fd, buf, size));
664 }
665
666 ssize_t
667 write(int fd, const void *buf, size_t size)
668 {
669 extern ssize_t __write(int, const void *, size_t);
670 return (__write(fd, buf, size));
671 }
672
673 /*
674 * ASCII versions of ctype character classification functions. This avoids
675 * pulling in the entire locale framework that is in libc.
676 */
677
678 int
679 isdigit(int c)
680 {
681 return ((c >= '0' && c <= '9') ? 1 : 0);
682 }
683
684 int
685 isupper(int c)
686 {
687 return ((c >= 'A' && c <= 'Z') ? 1 : 0);
688 }
689
690 int
691 islower(int c)
692 {
693 return ((c >= 'a' && c <= 'z') ? 1 : 0);
694 }
695
696 int
697 isspace(int c)
698 {
699 return (((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n') ||
700 (c == '\v') || (c == '\f')) ? 1 : 0);
701 }
702
703 int
704 isxdigit(int c)
705 {
706 return ((isdigit(c) || (c >= 'A' && c <= 'F') ||
707 (c >= 'a' && c <= 'f')) ? 1 : 0);
708 }
709
710 int
711 isalpha(int c)
712 {
713 return ((isupper(c) || islower(c)) ? 1 : 0);
714 }
715
716 int
717 isalnum(int c)
718 {
719 return ((isalpha(c) || isdigit(c)) ? 1 : 0);
720 }
|