<div dir="ltr"><div>Hello Gedare,</div><div>As you suggested, I have placed nbm.c in libc/search directory. This directory contains hash.h, db_local.h, hash.c. And all these are required by ndbm.<br></div><div>.</div><div>Here newlib got successfully compiled and It was generating function symbols.</div><div>.</div><div>After that when i added the patch to RSB, and tried to compile a test to check if ndbm is ported successfully or not.</div><div>It gave me error:</div><div>........</div><div>........<br></div><div><span style="font-family:courier new,monospace">mv -f fileio/.deps/fileio-init.Tpo fileio/.deps/fileio-init.Po<br>sparc-rtems5-gcc -DHAVE_CONFIG_H -I. -I/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples -I. -I/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/include -I/home/varodek/development/rtems/kernel/rtems/cpukit/include -I/home/varodek/development/rtems/kernel/rtems/cpukit/score/cpu/sparc/include -I/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/lib/libbsp/sparc/erc32/include -I/home/varodek/development/rtems/kernel/rtems/bsps/include -I/home/varodek/development/rtems/kernel/rtems/bsps/sparc/include -I/home/varodek/development/rtems/kernel/rtems/bsps/sparc/erc32/include -DT_FILE_NAME='"init.c"' -I/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/../support/include -mcpu=cypress -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -MT hello/hello-init.o -MD -MP -MF hello/.deps/hello-init.Tpo -c -o hello/hello-init.o `test -f 'hello/init.c' || echo '/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/'`hello/init.c<br>In file included from /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/hello/init.c:17:0:<br>/home/varodek/development/rtems/5/sparc-rtems5/include/ndbm.h:43:10: fatal error: db_local.h: No such file or directory<br> #include <db_local.h><br> ^~~~~~~~~~~~</span></div><div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:courier new,monospace">.</span></div><div><span style="font-family:courier new,monospace"></span>I found that db_local.h is not present in rtems/5 directory.</div><div><br></div><div>Thank you</div><div>Vaibhav Gupta<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 21, 2019 at 1:57 AM Vaibhav Gupta <<a href="mailto:vaibhavgupta40@gmail.com">vaibhavgupta40@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
newlib/libc/include/ndbm.h | 84 +++++++++++++<br>
newlib/libc/search/Makefile.am | 1 +<br>
newlib/libc/search/ndbm.c | 214 +++++++++++++++++++++++++++++++++<br>
3 files changed, 299 insertions(+)<br>
create mode 100644 newlib/libc/include/ndbm.h<br>
create mode 100644 newlib/libc/search/ndbm.c<br>
<br>
diff --git a/newlib/libc/include/ndbm.h b/newlib/libc/include/ndbm.h<br>
new file mode 100644<br>
index 000000000..f89f97dd0<br>
--- /dev/null<br>
+++ b/newlib/libc/include/ndbm.h<br>
@@ -0,0 +1,84 @@<br>
+/*-<br>
+ * SPDX-License-Identifier: BSD-3-Clause<br>
+ *<br>
+ * Copyright (c) 1990, 1993<br>
+ * The Regents of the University of California. All rights reserved.<br>
+ *<br>
+ * This code is derived from software contributed to Berkeley by<br>
+ * Margo Seltzer.<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ * notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ * notice, this list of conditions and the following disclaimer in the<br>
+ * documentation and/or other materials provided with the distribution.<br>
+ * 3. Neither the name of the University nor the names of its contributors<br>
+ * may be used to endorse or promote products derived from this software<br>
+ * without specific prior written permission.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND<br>
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE<br>
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
+ * SUCH DAMAGE.<br>
+ *<br>
+ * @(#)ndbm.h 8.1 (Berkeley) 6/2/93<br>
+ * $FreeBSD$<br>
+ */<br>
+<br>
+#ifndef _NDBM_H_<br>
+#define _NDBM_H_<br>
+<br>
+#define __DBINTERFACE_PRIVATE<br>
+<br>
+#include <db_local.h><br>
+<br>
+/* Map dbm interface onto db(3). */<br>
+#define DBM_RDONLY O_RDONLY<br>
+<br>
+/* Flags to dbm_store(). */<br>
+#define DBM_INSERT 0<br>
+#define DBM_REPLACE 1<br>
+<br>
+/*<br>
+ * The db(3) support for ndbm always appends this suffix to the<br>
+ * file name to avoid overwriting the user's original database.<br>
+ */<br>
+#define DBM_SUFFIX ".db"<br>
+<br>
+typedef struct {<br>
+ void *dptr;<br>
+ int dsize; /* XXX Should be size_t according to 1003.1-2008. */<br>
+} datum;<br>
+<br>
+typedef DB DBM;<br>
+#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE<br>
+<br>
+__BEGIN_DECLS<br>
+int dbm_clearerr(DBM *);<br>
+void dbm_close(DBM *);<br>
+int dbm_delete(DBM *, datum);<br>
+int dbm_error(DBM *);<br>
+datum dbm_fetch(DBM *, datum);<br>
+datum dbm_firstkey(DBM *);<br>
+#if __BSD_VISIBLE<br>
+long dbm_forder(DBM *, datum);<br>
+#endif<br>
+datum dbm_nextkey(DBM *);<br>
+DBM *dbm_open(const char *, int, mode_t);<br>
+int dbm_store(DBM *, datum, datum, int);<br>
+#if __BSD_VISIBLE<br>
+int dbm_dirfno(DBM *);<br>
+#endif<br>
+__END_DECLS<br>
+<br>
+#endif /* !_NDBM_H_ */<br>
diff --git a/newlib/libc/search/Makefile.am b/newlib/libc/search/Makefile.am<br>
index 98920c3f4..a61107fb9 100644<br>
--- a/newlib/libc/search/Makefile.am<br>
+++ b/newlib/libc/search/Makefile.am<br>
@@ -9,6 +9,7 @@ GENERAL_SOURCES = \<br>
db_local.h \<br>
extern.h \<br>
hash.h \<br>
+ ndbm.c \<br>
page.h \<br>
qsort.c<br>
<br>
diff --git a/newlib/libc/search/ndbm.c b/newlib/libc/search/ndbm.c<br>
new file mode 100644<br>
index 000000000..bd9c71e4f<br>
--- /dev/null<br>
+++ b/newlib/libc/search/ndbm.c<br>
@@ -0,0 +1,214 @@<br>
+/*-<br>
+ * SPDX-License-Identifier: BSD-3-Clause<br>
+ *<br>
+ * Copyright (c) 1990, 1993<br>
+ * The Regents of the University of California. All rights reserved.<br>
+ *<br>
+ * This code is derived from software contributed to Berkeley by<br>
+ * Margo Seltzer.<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ * notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ * notice, this list of conditions and the following disclaimer in the<br>
+ * documentation and/or other materials provided with the distribution.<br>
+ * 3. Neither the name of the University nor the names of its contributors<br>
+ * may be used to endorse or promote products derived from this software<br>
+ * without specific prior written permission.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND<br>
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE<br>
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
+ * SUCH DAMAGE.<br>
+ */<br>
+<br>
+#if defined(LIBC_SCCS) && !defined(lint)<br>
+static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94";<br>
+#endif /* LIBC_SCCS and not lint */<br>
+#include <sys/cdefs.h><br>
+__FBSDID("$FreeBSD$");<br>
+<br>
+/*<br>
+ * This package provides a dbm compatible interface to the new hashing<br>
+ * package described in db(3).<br>
+ */<br>
+<br>
+#include <sys/param.h><br>
+<br>
+#include <stdio.h><br>
+#include <string.h><br>
+#include <errno.h><br>
+<br>
+#include <ndbm.h><br>
+#include "hash.h"<br>
+<br>
+/*<br>
+ * Returns:<br>
+ * *DBM on success<br>
+ * NULL on failure<br>
+ */<br>
+extern DBM *<br>
+dbm_open(const char *file, int flags, mode_t mode)<br>
+{<br>
+ HASHINFO info;<br>
+ char path[MAXPATHLEN];<br>
+<br>
+ info.bsize = 4096;<br>
+ info.ffactor = 40;<br>
+ info.nelem = 1;<br>
+ info.cachesize = 0;<br>
+ info.hash = NULL;<br>
+ info.lorder = 0;<br>
+<br>
+ if( strlen(file) >= sizeof(path) - strlen(DBM_SUFFIX)) {<br>
+ errno = ENAMETOOLONG;<br>
+ return(NULL);<br>
+ }<br>
+ (void)strcpy(path, file);<br>
+ (void)strcat(path, DBM_SUFFIX);<br>
+ return ((DBM *)__hash_open(path, flags, mode, 0, &info));<br>
+}<br>
+<br>
+extern void<br>
+dbm_close(DBM *db)<br>
+{<br>
+ (void)(db->close)(db);<br>
+}<br>
+<br>
+/*<br>
+ * Returns:<br>
+ * DATUM on success<br>
+ * NULL on failure<br>
+ */<br>
+extern datum<br>
+dbm_fetch(DBM *db, datum key)<br>
+{<br>
+ datum retdata;<br>
+ int status;<br>
+ DBT dbtkey, dbtretdata;<br>
+<br>
+ dbtkey.data = key.dptr;<br>
+ dbtkey.size = key.dsize;<br>
+ status = (db->get)(db, &dbtkey, &dbtretdata, 0);<br>
+ if (status) {<br>
+ dbtretdata.data = NULL;<br>
+ dbtretdata.size = 0;<br>
+ }<br>
+ retdata.dptr = dbtretdata.data;<br>
+ retdata.dsize = dbtretdata.size;<br>
+ return (retdata);<br>
+}<br>
+<br>
+/*<br>
+ * Returns:<br>
+ * DATUM on success<br>
+ * NULL on failure<br>
+ */<br>
+extern datum<br>
+dbm_firstkey(DBM *db)<br>
+{<br>
+ int status;<br>
+ datum retkey;<br>
+ DBT dbtretkey, dbtretdata;<br>
+<br>
+ status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);<br>
+ if (status)<br>
+ dbtretkey.data = NULL;<br>
+ retkey.dptr = dbtretkey.data;<br>
+ retkey.dsize = dbtretkey.size;<br>
+ return (retkey);<br>
+}<br>
+<br>
+/*<br>
+ * Returns:<br>
+ * DATUM on success<br>
+ * NULL on failure<br>
+ */<br>
+extern datum<br>
+dbm_nextkey(DBM *db)<br>
+{<br>
+ int status;<br>
+ datum retkey;<br>
+ DBT dbtretkey, dbtretdata;<br>
+<br>
+ status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);<br>
+ if (status)<br>
+ dbtretkey.data = NULL;<br>
+ retkey.dptr = dbtretkey.data;<br>
+ retkey.dsize = dbtretkey.size;<br>
+ return (retkey);<br>
+}<br>
+<br>
+/*<br>
+ * Returns:<br>
+ * 0 on success<br>
+ * <0 failure<br>
+ */<br>
+extern int<br>
+dbm_delete(DBM *db, datum key)<br>
+{<br>
+ int status;<br>
+ DBT dbtkey;<br>
+<br>
+ dbtkey.data = key.dptr;<br>
+ dbtkey.size = key.dsize;<br>
+ status = (db->del)(db, &dbtkey, 0);<br>
+ if (status)<br>
+ return (-1);<br>
+ else<br>
+ return (0);<br>
+}<br>
+<br>
+/*<br>
+ * Returns:<br>
+ * 0 on success<br>
+ * <0 failure<br>
+ * 1 if DBM_INSERT and entry exists<br>
+ */<br>
+extern int<br>
+dbm_store(DBM *db, datum key, datum data, int flags)<br>
+{<br>
+ DBT dbtkey, dbtdata;<br>
+<br>
+ dbtkey.data = key.dptr;<br>
+ dbtkey.size = key.dsize;<br>
+ dbtdata.data = data.dptr;<br>
+ dbtdata.size = data.dsize;<br>
+ return ((db->put)(db, &dbtkey, &dbtdata,<br>
+ (flags == DBM_INSERT) ? R_NOOVERWRITE : 0));<br>
+}<br>
+<br>
+extern int<br>
+dbm_error(DBM *db)<br>
+{<br>
+ HTAB *hp;<br>
+<br>
+ hp = (HTAB *)db->internal;<br>
+ return (hp->error);<br>
+}<br>
+<br>
+extern int<br>
+dbm_clearerr(DBM *db)<br>
+{<br>
+ HTAB *hp;<br>
+<br>
+ hp = (HTAB *)db->internal;<br>
+ hp->error = 0;<br>
+ return (0);<br>
+}<br>
+<br>
+extern int<br>
+dbm_dirfno(DBM *db)<br>
+{<br>
+ return(((HTAB *)db->internal)->fp);<br>
+}<br>
-- <br>
2.21.0<br>
<br>
</blockquote></div>