From nobody Tue Feb 10 23:53:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1696376396; cv=none; d=zohomail.com; s=zohoarc; b=M/fVLxCujtnm02i2b0CXWyAzDWKvKvCKTADI3JmNzkoZ1da4sjHvZUe1uWbEZWyup9MfsVLs1XKpiRfgcL0clVF6HKhGFoOrI5hrvVSvL6mwnywAQM+hQ7RYQXJpzdICgNZRHWvE4hAohc4n2+xLeUv8odOV92ITIByppPDM9fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376396; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tN2OEe5rYzQGfb+nOOMon2seHs5SrR+EQ42mg0JPMFg=; b=KBg7xW77ro26RDExO6BoAeuyu22yUJIfAQu2jedz0+SO9dRg8iZldQZ0YdHvve9S+t1EraPg5sCIlCR23v5EtLuRJq1xUQOwfqLQbOJSIYpaNZeXr2rY0mxpHbJKUlFYYad7QqwVYzOBxokZSSgiAz+C5Edf4BVuTxhVfwr/bJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376396489267.33244129381114; Tue, 3 Oct 2023 16:39:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovI-00047P-3H; Tue, 03 Oct 2023 19:35:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnovG-00045h-Aw for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:26 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovE-000719-M8 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:26 -0400 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-79fe6da0095so60241539f.0 for ; Tue, 03 Oct 2023 16:35:24 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376123; x=1696980923; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tN2OEe5rYzQGfb+nOOMon2seHs5SrR+EQ42mg0JPMFg=; b=oRtvZQN/ok44oUDkrKAQJLiElIfAAADDhzzQHhinGmjDVcDOz1VNHG63sshI4+c/B8 T60vOK/eDdoOvHbtx53o2tnwamDtAGNMYWgTQFBDOOKdOXHw1OA3K2IuDXb/sQ4VJ+2L JKui/M9OzbLDyxtiDzfNmB8ADYp7Iv9wl3A6iAoNqGb9xh6O8fVHZpp5A9vz9JPXcnln YmU+nsdwK3rpuzVq9QTARHo1MbIxDSLLuj+zqrAJPTWfay+Z/C4HYCUY2o1PZVH18iFl f2E6fFrjwPNpTxFsrQyyOH8yZcsVlWMKzF2YXT4k/08bg48LG/jI5siSZ9VPjaJUxyo1 Re0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376123; x=1696980923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tN2OEe5rYzQGfb+nOOMon2seHs5SrR+EQ42mg0JPMFg=; b=FJyGCu4/dkt+qF+k9W3vfrfoMMJTKgkt29RbhD3x98fZWzu6NhHJVBYd3wYy7avNvA +XVrNSCPSEsv1U8uxkhG+U2DYghsn4yK0ztwclzS26pR+Sg/Ku0OBwu3Mr9p4uLJWcOA 8dwLQNt8ii0JxPS2qWyYOIbjvXIz62qo9H0ZNs9eijH2fGMH4M1pi1rxtxMHuiAPKS+t 7lyYHBwJ7PjWnN53WXUVgEprd6c9/ucX+AnIKObMwSYq6eLE/sz03axyYh/MR/6g72DW k9R3C1gmYHy55XInBn8zNWWi5WlrwpXyqIYaEhjLpEul50UQ0z0vMwYXVV8YE1cEY43U hPFA== X-Gm-Message-State: AOJu0YyO0rtMV/BZp9qrKA2Umx7L1OG3yBfbFX0SrBDVgU4A7OPNeSrE YaNT+dSZFo4J9vvqSc6GrO50zLU19YM0jgHhJIdLAA== X-Google-Smtp-Source: AGHT+IGu73C870FKUKyG6qdiMQofMSs+XPxu0tSixF/UVsAwldP05qJ6CzVK6ArPBhsKGAqD3rpasw== X-Received: by 2002:a05:6602:220e:b0:786:f352:e3d4 with SMTP id n14-20020a056602220e00b00786f352e3d4mr983515ion.7.1696376123392; Tue, 03 Oct 2023 16:35:23 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 18/51] bsd-user: Implement getpriority(2) and setpriority(2). Date: Tue, 3 Oct 2023 17:31:42 -0600 Message-ID: <20231003233215.95557-19-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376398180100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-19-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 24 ++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 2c1a9ae22fa..9a8912361f6 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -390,4 +390,28 @@ static inline abi_long do_bsd_ptrace(abi_long arg1, ab= i_long arg2, return -TARGET_ENOSYS; } =20 +/* getpriority(2) */ +static inline abi_long do_bsd_getpriority(abi_long which, abi_long who) +{ + abi_long ret; + /* + * Note that negative values are valid for getpriority, so we must + * differentiate based on errno settings. + */ + errno =3D 0; + ret =3D getpriority(which, who); + if (ret =3D=3D -1 && errno !=3D 0) { + return -host_to_target_errno(errno); + } + + return ret; +} + +/* setpriority(2) */ +static inline abi_long do_bsd_setpriority(abi_long which, abi_long who, + abi_long prio) +{ + return get_errno(setpriority(which, who, prio)); +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 1a760b13808..71a2657dd0f 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -359,6 +359,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_ptrace(arg1, arg2, arg3, arg4); break; =20 + case TARGET_FREEBSD_NR_getpriority: /* getpriority(2) */ + ret =3D do_bsd_getpriority(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_setpriority: /* setpriority(2) */ + ret =3D do_bsd_setpriority(arg1, arg2, arg3); + break; + =20 /* * File system calls. --=20 2.41.0