help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make loadable extension library


From: Tim Murphy
Subject: Make loadable extension library
Date: Thu, 29 Oct 2015 19:02:13 +0000

Hi,

I apologise if this is the wrong list for this.

For a time (hopefully short :-) )  I have no employer so I can at last make
some open source contributions.

This is a library containing a few useful functions that one can use with
the "load" directive in a makefile:

https://bitbucket.org/tnmurphy/extramake

I'm adding more but it currently contains $(equals) $(siphash24) and
$(strlen).

This makefile snippet shows an example of how one might use the hash
function:


############################################
SOURCES:=proga.c progb.c
OBJECTS:=$(SOURCES:.c=.o)

include xtra.mk
-load $(XTRA_OUTPUTDIR)/hash$(XTRA_EXT)

LIBVERSION:=$(siphash24 $(SOURCES))
LIBNAME:=prog_$(LIBVERSION).so

# Rules for building build $(LIBNAME)
........

include hash.mk  # rules for building the module.
############################################

At the moment it all only builds on Linux because the build scripts are
specific - but there's
no major reason why it couldn't be made to work on other platforms quite
easily.

I do note a couple of issues with the GNU make API for loadable modules:

1) The return value must be allocated by the function, after which make
copies it into a buffer and deallocates it.  This seems very inefficient
particularly in cases where the output length is not of pre-calculable
length.  Sometimes one is forced to implement a variable sized buffer
anyhow and the fact of there being no gmk_realloc() makes this doubly
inefficient since one has to use one's own variable buffer for the
calculation then gmk_allocate() an equally sized buffer, copy the result
into it and return.  It seems as if it would be much better to expose GNU
make's variable buffer interface and cut out the extra memory allocations
.
This issue has made me not submit a function that I consider very useful.

2) There are some functions for seeking tokens in a string that should also
be exposed - to help functions process lists.


Regards,

Timothy N Murphy


reply via email to

[Prev in Thread] Current Thread [Next in Thread]