Port tempname to Rust #103

Open
Wilfred opened this Issue Jan 21, 2017 · 3 comments

Projects

None yet

2 participants

@Wilfred
Owner
Wilfred commented Jan 21, 2017

We could straightforwardly replace gen_tempname and try_tempname with Rust implementations, probably from an existing crate.

This would let us remove tempname.c entirely.

@Wilfred Wilfred added the help wanted label Jan 21, 2017
@DavidDeSimone
Contributor

I can grab this if no one else is interested.

@Wilfred
Owner
Wilfred commented Jan 22, 2017

It's yours! :)

@DavidDeSimone
Contributor

Update on this. Open invite to anyone who spots any errors to correct me.

After investigation, it looks like __gen_tempname and __try_tempname are glibc functions, part of an internal API. If you attempt to compile emacs with a version of the c standard library that does not provide them, emacs will provide an implementation via tempname.c

It looks like emacs only uses this functions for an implementation of mkostemp, which is used in a number of different places in the code base. w32.c provides a custom implementation of this function for windows that does not utilize __gen_tempname or __try_tempname. __try_tempname only seems to be used by __gen_tempname. The ability to create a temporary directory, or to check if the temporary file exists via these functions seems to go unused in the emacs code base.

From my perspective, it seems that we want a rust-based replacement for mkostemp, that can be used cross platform. It looks like there are a number of solid crates in this space that can give us what we need. After implementing this, I would then delete the implementation of mkostemp in w32.c, and the implementation of __gen_tempname and __try_tempname, and update the places in code that use mkostemp to use our new rust function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment