Opened 4 days ago

Last modified 2 days ago

#71265 new enhancement

Adding pthread_[f]chdir_np to legacy-support - contribution guidelines?

Reported by: RJVB (René Bertin) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: fhgwright (Fred Wright), mascguy (Christopher Nielsen)
Port: legacy-support

Description (last modified by RJVB (René Bertin))

I have come across an application (not currently in MacPorts; Firefox Dynasty for "legacy" systems) that can make an unprotected call to pthread_chdir_np or pthread_fchdir_np, two functions that were introduced in 10.12 but were available as syscalls from 10.5 onwards.

Based on old Chromium code it should be possible to provide these functions on 10.11 and earlier with a pair of simple wrappers:

int pthread_chdir_np(const char* dir)
{
  return syscall(SYS___pthread_chdir, dir);
}

int pthread_fchdir_np(int fd)
{
  return syscall(SYS___pthread_fchdir, fd);
}

I realise port:legacy-support is mainly intended for use with MacPorts and doesn't aim to provide every possible missing symbol, so I'd be perfectly happy with some guidelines or pointers how to add these 2 wrappers the proper way in a personal fork of the repo (i.e. in such a way that they only get included on 10.11 and earlier).

EDIT: I attached a proof of concept implementation that works for me on 10.9 , based on my understanding of the implementation for other added symbols.

Reason I'm filing a trac ticket is that there is no dedicated issue tracker, and the application in question could make a valuable new port for other owners of retro systems (i.e. Firefox v132 that runs on at least 10.8 and up).

(I did try to contribute a patch "upstream" but let's just say that my efforts weren't appreciated and the maintainer not particularly interested in bug reports but more in calling names on here).

Attachments (1)

patch-add-pthread_chdir_np.diff (4.6 KB) - added by RJVB (René Bertin) 2 days ago.
draft implementation

Download all attachments as: .zip

Change History (2)

Changed 2 days ago by RJVB (René Bertin)

draft implementation

comment:1 Changed 2 days ago by RJVB (René Bertin)

Description: modified (diff)

Re: the patch: I'm not certain about the "dummy symbols" (which is what they seem to be) in add_symbols.c, nor if __MPLS_SDK_SUPPORT_PTHREAD_CHDIR_NP__ should be used.

Judging from 3rd party code using these functions it would appear that they are not defined in any header files but are usually defined with availability macro:

extern "C" {
 int pthread_chdir_np(const char* dir) API_AVAILABLE(macosx(10.12));
 int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12));
}

Does this mean they should actually be defined conditionally to avoid compilation errors in case the above definitions evaluate to empty space?

Last edited 2 days ago by RJVB (René Bertin) (previous) (diff)
Note: See TracTickets for help on using tickets.