Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-05

How to add new function related to MAC OS X

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roland Turcan

Hello

1.

I want to add new function for Mac OS X which calls FCNTL with F_FULLSYNC to the existing source tree, but I am really confused from the files to be changed/added. I see that there are many include files which declare functions for Mac OS X, but they come from *BSD directories. I know, that it is because of compatibility with *BSD, but the interface comes from BSD dir and implementation from FreeBSD dir.

How is it with directory tree among plaftforms?

2.

I want to use SysCall unit which is located in /rtl/unix, but it cannot find it. When I use Unix unit I have not problem. But they are in the same directory?!

Thanks in advance for any reply.

Marco van de Voort
to Roland Turcan

In our previous episode, Roland Turcan said:

Show quoted text 6 lines
I want to add new function for Mac OS X which calls FCNTL with F_FULLSYNC to the existing source tree, but I am really confused from the files to be changed/added. I see that there are many include files which declare functions for Mac OS X, but they come from *BSD directories. I know, that it is because of compatibility with *BSD, but the interface comes from BSD dir and implementation from FreeBSD dir.

The BSD dir contains the common part of the *BSD rtls + OS X. The Unix dir contains all stuff common to all unices. The inc and objpas dirs contain files common to all platforms.

Directories with an OS name (Darwin,FreeBSD) are for that specific target. OS X stuff is in Darwin.

Maybe some of the confusion comes from the fact that Darwin is a strictly libc port, while FreeBSD and Linux are dual ports (syscalls or libc, with syscall as default)

I want to use SysCall unit which is located in /rtl/unix, but it cannot find it. When I use Unix unit I have not problem. But they are in the same directory?!

It does not exist for OS X. The Mac OS X maintainer only supports the libc interface, the headers of which are mostly the "c" and "cdecl" inc files in unix/.

As far as I know the OS X syscall interface is nearly the same as FreeBSD's for the base set.

Jonas Maebe
to Marco van de Voort
Marco van de Voort wrote
The Mac OS X maintainer only supports the libc interface,

It is Apple that only supports the libc interface (and yes, you probably expected this reaction). There is no syscall interface for direct use by applications on Mac OS X (well, no more than there is a kernel API on Linux for use by closed source kernel modules anyway: nothing suported, and guaranteed by their developers to break every now and then).

As far as I know the OS X syscall interface is nearly the same as FreeBSD's for the base set.

And it slightly changes from time to time.

Jonas

Jonas Maebe
to Roland Turcan: Hello 1. I want to add new function for Mac OS X which calls FCNTL with F_FULLSYNC to the…
Roland Turcan wrote
I want to add new function for Mac OS X which calls FCNTL with F_FULLSYNC to the existing source tree, but I am really confused from the files to be changed/added.

Such a function will never be added to the rtl. The fcntl function is already there and you can use it. The only thing that can be added is the F_FULLSYNC constant to some Darwin-specific include file. Its value is 51, in case you want to add the constant declaration to one of your own units.

Jonas

PS: note that you don't have F_FULLSYNC-like functionality on many other OSes (there you always lose the data in case of a power failure before the data has been flushed from the drive's internal caches), and that it will significantly slow down your program if you don't watch out. There was a whole controversy a few years back about MySQL being dog slow on Mac OS X compared to on other OSes, and the reason turned out to be their use of fcntl(F_FULLSYNC) (although it's of course good practice from a data integrity point of view).

Jonas Maebe
to Jonas Maebe
Jonas Maebe wrote
The only thing that can be added is the F_FULLSYNC constant to some Darwin-specific include file.

Done in svn, along with a bunch of other Darwin-specific fcnlt constants, but note that it's F_FULLFSYNC, not F_FULLSYNC. Also keep in mind that not all those constants (and therefore the functions they represent) are available on older Mac OS X versions. F_FULLFSYNC is available since 10.3.x though, so you're probably safe there.

Jonas