Skip to content

Conversation

@badboy
Copy link
Member

@badboy badboy commented Jan 6, 2026

No description provided.

@badboy badboy requested a review from a team as a code owner January 6, 2026 14:46
@badboy badboy requested review from jeddai and removed request for a team January 6, 2026 14:46
@badboy badboy marked this pull request as draft January 6, 2026 14:47
@badboy
Copy link
Member Author

badboy commented Jan 6, 2026

ok, this is .. getting confusing. Guess we did the right thing already?
Apple makes it confusing and we add some confusion on top.

We currently report it like this in client_info:

client_info field Sysctl var name sysctl field
architecture machine HW_MODEL
device_model model HW_MACHINE

my M4:

❯ ./sys
CTL_HW HW_MODEL: Mac16,8
CTL_HW HW_MACHINE: arm64
CTL_HW HW_MACHINE_ARCH: (null)

sample app in the simulator (iPhone 17):

HW_MODEL: Mac16,8
HW_MACHINE: arm64
MACHINE_ARCH: Unknown

sample app on my iPad:

HW_MODEL: J418AP
HW_MACHINE: iPad8,10
MACHINE_ARCH: Unknown

At least it's documented now.

Details

gcc -o sys sys.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/sysctl.h>

char *my_sysctl(int ctl, int ht) {
  static char buf[48];
  size_t len = sizeof(buf);

  int mib[] = { ctl, ht };
  int ret = sysctl(mib, 2, &buf, &len, NULL, 0);
  if (ret == -1) {
    return NULL;
  }

  return strdup(buf);
}

#define SYSCTL(ctl, hw) do { \
  char *res = my_sysctl(ctl, hw); \
  printf("%s %s: %s\n", #ctl, #hw, res); \
  free(res); \
} while (0);

int main(int argc, char** argv)
{
  SYSCTL(CTL_HW, HW_MODEL);
  SYSCTL(CTL_HW, HW_MACHINE);
  SYSCTL(CTL_HW, HW_MACHINE_ARCH);
  return 0;
}

@badboy badboy closed this Jan 6, 2026
@badboy badboy deleted the push-oxuxsrqlvsxl branch January 6, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants