Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gestalt selector for Intel chips?



Title: Re: Gestalt selector for Intel chips?
Historically, it was a global.
In modern times, "errno" is a macro that calls a private function (I think it's called __error() or something). This allows it to be thread-safe. By and large, though, you can treat it as if it were a global variable.


George Malayil-Philip wrote:
Hi,
    http://www.unix.org/whitepapers/reentrant.html
That should explain it. I think it is a globally defined variable which is included by errno.h.

Regards
George M.P.


A few days ago, I asked if there was a way to detect if my program was running under Rosetta. Several people sent me this link:

http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/universal_binary_exec_a/chapter_7_section_7.html

However, the code there doesn't make any sense. Check out the 2nd function:

int is_pid_native (pid_t pid)

{
    int ret = 0;
    size_t sz = sizeof(ret);
 

    if (sysctlbyname_with_pid("sysctl.proc_native", pid, 
                &ret, &sz, NULL, 0) == -1) {

         if (errno == ENOENT) {
            // sysctl doesn't exist, which means that this version of Mac OS 
            // pre-dates Rosetta, so the application must be native.

            return 1;
        }

        fprintf(stderr, "is_pid_native: sysctlbyname_with_pid  failed:" 
                "%s\n", strerror(errno));

        return -1;
    }

    return ret;
}

Where is this "errno" variable that's being compared in the 2nd if statement? It simply doesn't exist. Same for the first function listing... it uses "errno" but errno isn't defined anywhere. Am I really dense, or is this listing wrong?

I'd fix it if I knew what I was doing... Should it be using the "sz" variable in place of errno?

-Vern



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: Gestalt selector for Intel chips? (From: George Malayil-Philip <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.