Debian Codegraph @

src/libmisc.scm

raw
1 ;;;
2 ;;; libmisc.scm - miscellaneous built-in procedures
3 ;;;
4 ;;; Copyright (c) 2000-2024 Shiro Kawai <[email protected]>
5 ;;;
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
9 ;;;
10 ;;; 1. Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
12 ;;;
13 ;;; 2. Redistributions in binary form must reproduce the above copyright
14 ;;; notice, this list of conditions and the following disclaimer in the
15 ;;; documentation and/or other materials provided with the distribution.
16 ;;;
17 ;;; 3. Neither the name of the authors nor the names of its contributors
18 ;;; may be used to endorse or promote products derived from this
19 ;;; software without specific prior written permission.
20 ;;;
21 ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 ;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 ;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 ;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ;;;
33
34 (select-module gauche.internal)
35 (inline-stub
36 (.include "gauche/priv/configP.h"
37 "gauche/vminsn.h"))
38
39 ;;;
40 ;;; Miscellaneous
41 ;;;
42
43 (select-module gauche)
44
45 (define-cproc has-setter? (proc) ::<boolean> Scm_HasSetter)
46
47 (define-cproc undefined () (inliner CONSTU) (return SCM_UNDEFINED))
48 (define-cproc undefined? (obj) ::<boolean> :constant SCM_UNDEFINEDP)
49
50 (define (warn fmt . args)
51 (unless (sys-getenv "GAUCHE_SUPPRESS_WARNING")
52 (apply format (current-error-port) (string-append "WARNING: " fmt) args)
53 (flush (current-error-port))))
54
55 ;; uninitialized value is only used in the compiler and should never be leaked
56 ;; out to the userland.
57 (select-module gauche.internal)
58 (define-cproc %uninitialized () (return SCM_UNINITIALIZED))
59
60 ;; Debug label
61 (select-module gauche)
62 (define-cproc debug-label (obj) (return (Scm_Sprintf "@%lx" obj)))
63
64 ;; Foreign pointer (may be in libsys.scm?)
65
66 (select-module gauche)
67
68 (define-cproc foreign-pointer-invalid? (fp::<foreign-pointer>) ::<boolean>
69 Scm_ForeignPointerInvalidP)
70
71 (define-cproc foreign-pointer-invalidate! (fp::<foreign-pointer>) ::<void>
72 Scm_ForeignPointerInvalidate)
73
74 (define-cproc foreign-pointer-attributes (fp::<foreign-pointer>)
75 Scm_ForeignPointerAttr)
76
77 (define-cproc foreign-pointer-attribute-get (fp::<foreign-pointer>
78 key :optional fallback)
79 Scm_ForeignPointerAttrGet)
80
81 (define-cproc foreign-pointer-attribute-set! (fp::<foreign-pointer> key value)
82 Scm_ForeignPointerAttrSet)
83
84 ; for backward compatibility - deprecated
85 (define foreign-pointer-attribute-set foreign-pointer-attribute-set!)
86
87 ;;
88 ;; Static configuration
89 ;;
90
91 (select-module gauche.internal)
92 (define-cproc cond-features () Scm_GetFeatures)
93
94 (inline-stub
95 (define-constant SLIB_DIR (c (SCM_MAKE_STR_IMMUTABLE SLIB_DIR))))