Apple Darwin Manuel d'utilisateur Page 52

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 68
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 51
the writepos must not be allowed to overtake the read
position, so subtract one from the final value.
*/
#define BYTES_TO_WRITE(ringbuffer) (ringbuffer->readpos - \
ringbuffer->writepos + \
((ringbuffer->writepos >= ringbuffer->readpos) * \
ringbuffer->buflen) - 1)
The code reading from this buffer knows that it can always read from readpos forwards up to writepos (or
if writepos is less than readpos, it can read to the end of the buffer, then read from the start of the buffer
up to writepos). After reading, the read code updates readpos to reflect the location of the last byte read.
In a similar fashion, the code writing to this buffer knows that it can safely write from the writepos position
until it reaches readpos, wrapping around the end of the buffer if necessary. After writing, the write code
updates writepos to reflect the location of the last byte written.
Because only one process will ever modify either readpos or writepos, no synchronization between the two
processes is required. Note, however, that the reading code must protect readpos against other threads
within that process, and the writing code must do the same for writepos.
Launching the Helper Host
After you’ve build a helper host, the next step is to determine the architecture of the plug-in. For PEF/CFM
plug-ins, it is safe for you to assume that the plug-in contains 32-bit PowerPC executable code. For Mach-O
plug-ins, the method you should use varies according to the version of OS X being used.
For backward compatibility with versions of OS X prior to 10.5, your application should use the detection code
presented in the CheckExecutableArchitecture sample code. This sample code is straightforward and presents
a fairly easy way to determine which architecture to use for loading existing plug-ins.
In OS X v10.5 and later, you should use the CFBundle API. This API is safer as a long-term solution, because it
will support any binary format that is supported by that particular version of OS X, thus freeing you from the
need to alter the code as new binary formats are introduced. The relevant functions are:
CFArrayRef CFBundleCopyExecutableArchitecturesForURL(CFURLRef url);
CFArrayRef CFBundleCopyExecutableArchitectures(CFBundleRef bundle);
Cross-Architecture Plug-in Support
Launching the Helper Host
2012-12-13 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.
52
Vue de la page 51
1 2 ... 47 48 49 50 51 52 53 54 55 56 57 ... 67 68

Commentaires sur ces manuels

Pas de commentaire