<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 27, 2019 at 10:08 AM Aditya Upadhyay <<a href="mailto:aadit0402@gmail.com">aadit0402@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">On Thu, Jun 27, 2019 at 2:11 AM Vaibhav Gupta <<a href="mailto:vaibhavgupta40@gmail.com" target="_blank">vaibhavgupta40@gmail.com</a>> wrote:<br>
><br>
> Hello Gedare,<br>
> as you suggested, to use the group name of patch as 'newlib'.<br>
> I did that and then removed the line "%patch setup newlib -p1"<br>
> It has generated ndbm.h in include directory.<br>
><br>
<br>
You are applying the patches to RSB just for testing purpose. It would<br>
not show your contribution.<br>
This will only help you to tests your methods what you will be going<br>
to contribute to newlib.<br>
So figuring out the solution of this old header replacement or<br>
updating headers and submitting the patches to<br>
the newlib is recommended.<br></blockquote><div>Sure, I will complete the testsuite as soon as possible and then push the patch to newlib. <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>
I appreciate your effort. Have you figured out how would you be going<br>
to write the test cases for ndbm and ftw methods?<br></blockquote><div>I did tried to check for the ndbm using raw ndbm methods in testsuites/samples/hello/init.c: <a href="https://github.com/VARoDeK/rtems/blob/test_ndbm_presence/testsuites/samples/hello/init.c">https://github.com/VARoDeK/rtems/blob/test_ndbm_presence/testsuites/samples/hello/init.c</a></div><div>.</div><div>It showing the error:</div><div>/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld: hello/hello-init.o: in function `Init':<br>/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/hello/init.c:41: undefined reference to `dbm_open'<br>/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld: /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/hello/init.c:42: undefined reference to `dbm_store'<br>/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld: /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/hello/init.c:45: undefined reference to `dbm_fetch'<br>/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld: /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/samples/hello/init.c:49: undefined reference to `dbm_close'<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>
> Vaibhav Gupta<br>
><br>
> On Wed, Jun 26, 2019 at 8:41 PM Vaibhav Gupta <<a href="mailto:vaibhavgupta40@gmail.com" target="_blank">vaibhavgupta40@gmail.com</a>> wrote:<br>
>><br>
>><br>
>><br>
>> On Wed, Jun 26, 2019 at 8:35 PM Vaibhav Gupta <<a href="mailto:vaibhavgupta40@gmail.com" target="_blank">vaibhavgupta40@gmail.com</a>> wrote:<br>
>>><br>
>>> Hello,<br>
>>><br>
>>> Newlib is compiling successfully.<br>
>>> But when i applied patch to RSB. It is not generating ndbm.h inside rtems/5/sparc-rtem5/include this time.<br>
>>><br>
>>> I am following same steps again which I followed that day when ndbm.h was successfully generated.<br>
>>> Below are the log files generated by rsb build.<br>
>><br>
>> Although, before testing, I update RSB today (git pull). I figured that the configuration file, used by rsb for newlib, is now changed.<br>
>> .<br>
>> So i updated my steps accordingly. That is, I added the patch in that new configuration file.<br>
>> .<br>
>> According to logs, patch is applied I guess, but it is not generating ndbm.h in include directory.<br>
>>><br>
>>><br>
>>> On Wed, Jun 26, 2019 at 8:32 PM Vaibhav Gupta <<a href="mailto:vaibhavgupta40@gmail.com" target="_blank">vaibhavgupta40@gmail.com</a>> wrote:<br>
>>>><br>
>>>> ---<br>
>>>> newlib/libc/include/ndbm.h | 84 +++++++++++++<br>
>>>> newlib/libc/search/Makefile.am | 1 +<br>
>>>> newlib/libc/search/ndbm.c | 215 +++++++++++++++++++++++++++++++++<br>
>>>> 3 files changed, 300 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..3b42c60b0<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>
>>>> +/* 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>
>>>> +struct __db;<br>
>>>> +typedef struct __db DB;<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..8ac6d1f40<br>
>>>> --- /dev/null<br>
>>>> +++ b/newlib/libc/search/ndbm.c<br>
>>>> @@ -0,0 +1,215 @@<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 "db_local.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></div>