Date: Tue, 28 May 2002 19:52:36 -0700 From: "J. Mallett" <jmallett@FreeBSD.org> To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu> Cc: standards@FreeBSD.org Subject: Re: Q&D implementation of dlfunc() Message-ID: <20020528195236.A66528@FreeBSD.ORG>
next in thread | raw e-mail | index | archive | help
I would prefer to see this done in a proper way, or at least have some suitably abstracted interface to allow MD pointer munging/indexing by these functions for the purpose of returning function pointers, however using our toolchain on all of our supported architectures, your change is somewhat straightforward enough, however I wonder if it wouldn't be better to write this: rv = (uintptr_t)dlsym(handle, symbol); But that's just the way I've taken to writing such shims, and your way is as valid as any, functionally, I suppose. I would say to write it like that, as you essentially synthesise the "correct" way to swap data and function pointer values, on all our architectures. Here are my conversion functions, stemming from a conversation with Bruce Evans a while ago: typedef void (*convptr)(); convptr function_to_data_ptr(convptr function, uintptr_t *data) { memcpy(data, &function, sizeof(convptr)); return function; } convptr data_to_function_ptr(convptr *function, uintptr_t *data) { memcpy(function, data, sizeof(convptr)); return *function; } -- J. Mallett <jmallett@FreeBSD.org> FreeBSD: The Power To Serve To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020528195236.A66528>