* configure.in: Call AM_PROG_CC_STDC, to see what flags we should
[bpt/guile.git] / libguile / dynl-shl.c
CommitLineData
1edae076
MV
1/* dynl-shl.c - dynamic linking with shl_load (HP-UX)
2 *
96599e6a 3 * Copyright (C) 1990-1997 Free Software Foundation, Inc.
1edae076
MV
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 as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
82892bed
JB
17 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307 USA
1edae076
MV
19 *
20 * As a special exception, the Free Software Foundation gives permission
21 * for additional uses of the text contained in its release of GUILE.
22 *
23 * The exception is that, if you link the GUILE library with other files
24 * to produce an executable, this does not by itself cause the
25 * resulting executable to be covered by the GNU General Public License.
26 * Your use of that executable is in no way restricted on account of
27 * linking the GUILE library code into it.
28 *
29 * This exception does not however invalidate any other reasons why
30 * the executable file might be covered by the GNU General Public License.
31 *
32 * This exception applies only to the code released by the
33 * Free Software Foundation under the name GUILE. If you copy
34 * code from other Free Software Foundation releases into a copy of
35 * GUILE, as the General Public License permits, the exception does
36 * not apply to the code that you add in this way. To avoid misleading
37 * anyone as to the status of such modified files, you must delete
38 * this exception notice from them.
39 *
40 * If you write modifications of your own for GUILE, it is your choice
41 * whether to permit this exception to apply to your modifications.
82892bed 42 * If you do not wish that, delete this exception notice. */
1edae076
MV
43
44/* "dynl.c" dynamically link&load object files.
45 Author: Aubrey Jaffer
46 Modified for libguile by Marius Vollmer */
47
1edae076 48#include "dl.h"
803f85cc
MV
49#include <stdio.h>
50#include <string.h>
1edae076 51
80bc7890
MV
52static void *
53sysdep_dynl_link (fname, subr)
54 char *fname;
55 char *subr;
1edae076 56{
1edae076
MV
57 shl_t shl;
58
803f85cc
MV
59 /* Probably too much BIND_* flags */
60 shl = shl_load (fname, BIND_IMMEDIATE || BIND_FIRST ||
61 BIND_TOGETHER ||
62 BIND_VERBOSE || DYNAMIC_PATH, 0L);
1edae076 63 if (NULL==shl)
419e9e11
MV
64 {
65 SCM_ALLOW_INTS;
80bc7890 66 scm_misc_error (subr, "dynamic linking failed", SCM_EOL);
419e9e11 67 }
80bc7890 68 return shl;
1edae076
MV
69}
70
80bc7890
MV
71static void
72sysdep_dynl_unlink (handle, subr)
73 void *handle;
74 char *subr;
1edae076 75{
419e9e11
MV
76 if (shl_unload ((shl_t) handle))
77 {
78 SCM_ALLOW_INTS;
79 scm_misc_error (subr, "dynamic unlinking failed", SCM_EOL);
80 }
1edae076
MV
81}
82
80bc7890
MV
83static void *
84sysdep_dynl_func (symb, handle, subr)
85 char *symb;
86 void *handle;
87 char *subr;
1edae076 88{
803f85cc
MV
89 int status, i;
90 struct shl_symbol *sym;
419e9e11 91
803f85cc
MV
92 status = shl_getsymbols((shl_t) handle, TYPE_PROCEDURE,
93 EXPORT_SYMBOLS, malloc, &sym);
419e9e11 94
803f85cc
MV
95 for (i=0; i<status; ++i) {
96 if (strcmp(symb, sym[i].name) == 0) return sym[i].value;
97 }
419e9e11
MV
98
99 SCM_ALLOW_INTS;
803f85cc
MV
100 scm_misc_error (subr, "undefined function",
101 scm_cons (scm_makfrom0str (symb), SCM_EOL));
1edae076
MV
102}
103
80bc7890
MV
104static void
105sysdep_dynl_init ()
1edae076 106{
1edae076 107}