From patchwork Fri Feb 3 11:23:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 93171 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp544697qgi; Fri, 3 Feb 2017 03:25:43 -0800 (PST) X-Received: by 10.237.42.1 with SMTP id c1mr12282674qtd.10.1486121143140; Fri, 03 Feb 2017 03:25:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d77si19080139qkj.21.2017.02.03.03.25.42; Fri, 03 Feb 2017 03:25:43 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B0402609C5; Fri, 3 Feb 2017 11:25:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, SPF_HELO_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 035026066D; Fri, 3 Feb 2017 11:25:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 7BED8609D6; Fri, 3 Feb 2017 11:25:12 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10101.outbound.protection.outlook.com [40.107.1.101]) by lists.linaro.org (Postfix) with ESMTPS id 4BB5B609B6 for ; Fri, 3 Feb 2017 11:24:32 +0000 (UTC) Received: from AM2PR07CA0040.eurprd07.prod.outlook.com (10.163.24.178) by DB5PR07MB0805.eurprd07.prod.outlook.com (10.161.196.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.874.6; Fri, 3 Feb 2017 11:24:29 +0000 Received: from DB3FFO11FD032.protection.gbl (2a01:111:f400:7e04::190) by AM2PR07CA0040.outlook.office365.com (2a01:111:e400:8448::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.888.5 via Frontend Transport; Fri, 3 Feb 2017 11:24:28 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.35 as permitted sender) Received: from hybrid2.ext.net.nokia.com (131.228.2.35) by DB3FFO11FD032.mail.protection.outlook.com (10.47.217.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.874.2 via Frontend Transport; Fri, 3 Feb 2017 11:24:28 +0000 Received: from fihe3nok1348.nsn-intra.net (10.158.36.136) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34; Fri, 3 Feb 2017 13:24:26 +0200 Received: from mailrelay.int.nokia.com (10.130.128.21) by fihe3nok1348.nsn-intra.net (10.158.36.136) with Microsoft SMTP Server (TLS) id 15.1.466.34 via Frontend Transport; Fri, 3 Feb 2017 13:24:26 +0200 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v13BO0aQ009221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 3 Feb 2017 13:24:00 +0200 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v13BO0Hp009210 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 3 Feb 2017 13:24:00 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Fri, 3 Feb 2017 13:23:59 +0200 Message-ID: <1486121040-12393-1-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.35; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39410400002)(39860400002)(39850400002)(39450400003)(39840400002)(2980300002)(189002)(199003)(97736004)(53946003)(450100001)(107886002)(36756003)(81166006)(48376002)(38730400001)(50466002)(305945005)(189998001)(68736007)(50986999)(106466001)(105596002)(2351001)(6916009)(47776003)(22756006)(626004)(8676002)(110136003)(81156014)(5003940100001)(5660300001)(77096006)(2906002)(575784001)(33646002)(8936002)(50226002)(86362001)(356003)(92566002)(53936002)(579004); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR07MB0805; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD032; 1:50HeBUTvY4+IZKJtf4ywhOK7S4Sy9mDEOmqc0vi4PY+w24RIJrPve9SePh7sD19NtWcdYVhsjjavprioBYrVaL96G5xNx+mKLSa1QrJ8b6siqFhv4KKjl2EuIyLjhz9I/TimAnESxKMf+caC1kqt99/SdoHbMpBNpVEFst298icSwDMuRJkOA8H6smTFT2mKGG8CMYvOseH1jILgiLYLXb/aTkz2ZVr+vyat9un6B+OIG5+egoyaIL0wH+eSJnE4A6N418VnqDf8f14EOqOB8FDBR/Kio1nCdUWVb1/leZV+slK0QTl6UPzzCFITzpmH+m31inoMhe5FGo1u4I7ZNfx7y0GULagAcBjECRR+rP5cKfRtdXAkXMoXL1mAZNhraApFP7NBBunnXAT7fLSi69blQWJbuFZ4pKwoKy19d1q31g9RNplDKNJwmPKuzOMiP4AurtoScdea/oIM8Af6+g== X-MS-Office365-Filtering-Correlation-Id: a1c5019c-9767-4364-60a2-08d44c2737b6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB5PR07MB0805; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0805; 3:RKQ18VtMegyGGaciukQZWONKqnt+1Sr9a1pRvHj9LAa3QFJ8byAzp/gy412drP1/jzeUpxf1Qpdt2sx+AulVlUiGNipvAacPyc5DPUyQdW8kXCmZqDGzvYBzRlY6jRLoA+OSGYpEqr9YGIfEcAoR8OReHu16N8NOWO2iElCjcD6aPXoDFGbl3OyrryWSwsnWjnHgPBLU3lJbqIPFAp6qfT1FXZ9UnzOR+tAMplRjjDTXh2zgwxfI8JM5C6J/oPLzvgUejCkbOsjDK3NCHI4exY/LkPgncQHheKus1Jb8d++QCs+SwTl9mUKiBmmPM+LR8HBnW+jE5SChGaPQXSmC6ABIp5ZYvOHpZKQEpZvppNw=; 25:4aFTnC7SwrcPAuet82aSWAskYuCRwiny0x17iKLaKr4/S/x1XSmZ8nJj/u16w7SX/nRolsTLNN7+aBW2mDFxzM4jiwkBLmBiECH0LezZgG4OujFEge35fqgSlH3zt630lJGsJWOXQD2eOW+VR9z8qtoyicilcL5U9lELNEe+owIdNKiIAyiaYAsaOpcRjd+vIhx/bwoMAQjS28rds7CwUryt3oCIdBffVmi5tbMJAuO06jhD6c+9nKBec39Lq4tJOhmiY6n9fTHWP9Q9nA/owrZpO7f5IMI4U3as3cLSbwLK20Et1DOP4cS9ABRj+OTDFHvvnHn2lLeQ04J5jaZEiOTBilFI6qw0vcdeK1VIWr3FEV8ZZjT+NB4ZE5Zo3lTQIgzHPL5qZ/NXaYdfhgioTHFdrRi8NqYFry+k9mBcGmbjWd5tJ5fIo9mVGmy3Ppvoq0DTnDuTt3HB4uhie2sNsw== X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0805; 31:ZPZtajQR0xwoBehdxYFnMdkdb/tEkiycyuy+Le5STNBqEYAbFkp5xnCkauYJkukVyxVUlJyLu4fek/PUHeS2joD0nEuZN3busWHGNIk5F365j56aMMUw+FfPw8v08t7iRwJppOl2ij0faEmG8IRo4uDQZjtO1WFFYrcRd5svM7NZCc4lPyjaHPXmLBUYFVA/qzMIKnF323h9xsUqdFJgMXm2aCHxMhkvfLTT+QOkCOx+TliCNjZgN7bcVkgq7BkjK/UZRVgkc4uqsQzSExaMwg==; 20:tpNF9Mg+McIa6B8uqdcKg4B8n3EP/Z3jI/UBQ/uJYg9xVKWKbv8Ri7/lYVCFqfuHC+XcgQo42V9BRqPQEOCnZlhAoGfvBuCmfzAgwqQaXJRQfNo15049M3gTN5EAkov3mwTX1ximLNk2Zu05874PHvBo8Rn0iSXI7MSvWfW7BD9LPEDatCMk35/uEi+C4rtoAFrZI2hYhAs1IIgtN2vhPPLTETJcnrYQ4hH7GfgqEbDNrn8NOPhBrmezr4THnYJWB8bpIM6mucUOqkynyIGdDcz0jVHx5mSmtdOwRjSlWzQB2PjlL1IiJA6u0CC+fMoRQGXuJtzZ5/VXNkzFHzYCSzhDHf8PCGq8wc23CM30b8UE+O8QFjTYRAjLffJ2sXyHwQWTOuIpWbPnDKgDMd741pBRUfv/CD0lO/Abfq63pt7bAAFD3IS56lLhodwyYwyn3+Enyd50F7bjOMg+WZBwSJIV731hJWUyvBXjY7EwZDwbrp0Elsir3rbIyHAXLImP1q7Ywmefd/3GcnvjRu5+boNYZbtfpa/dLJTZifjXi+j2lxId8BopLAQEVCLfQx/9Bthodhsb1ry2tdqqQ6JoxhTjjanTwwCy4wkcrxFsOOg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13016025)(8121501046)(13018025)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123555025)(20161123558025)(20161123562025)(20161123560025)(6072148); SRVR:DB5PR07MB0805; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB0805; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0805; 4:B+Y0ltuyVxzLVuBGXfI6c7sc24jVwQbwWsdSpe8JcxJmalqNL5uY0sqfaQ48uNkhys/uuB+KSrOLazz2Vfz+mg7/kkwCwEN6BUvDGP/lCJJszGZbX71mUubj9Yzk38TMcmYLJC0bBQ/cEwwKNP79ia+l2uEaFypqY/E+8pEGb8xx99Ey05WEWSBCwt3JWAN68jUfkV8PB8u5pgL/2zrLaIOu3XOQg0brOvjr1wGQWRHvT41+sZgzEcSwcqEJHKfQrwOLcCpxVlyslgLYO1cGBzGf0iHcFc3tOsAw6/S1g4hd2OCnSYc3BQjo3hVCukbrQCQ/WfYvO1HE2D4VIxJpqT1su3Tjk0QxwUXJD+4J40MB6SJ8McUJUfWINKl5dNjH9/PPqtDBzebReXPMtXY6JgC0WBMuwHkw9xiX07pR0CVkyj3bXHE2XYSCV0Peyhj1/8VbnmTXD8Zq1OZKJezUN8TXjefwn7UCMh8jxz+rCLF63xrd4/j4UVwwo61r//4WcKYge7OxFp0v1JzOwAMw9lkL6iUQ8Zy/h2Ph4y/2UlE1z9WyGhn6eb8+HVynTn8FJ1bXNhp8++QL37PQZ6Uz33CqXGKggaK72XJNX+cpeyLibEKinLs4u921UN8P1drpuEOblRTzcfUQQ0W2sGdKi5w9HAeJQRoicGlyuxrE2Ms= X-Forefront-PRVS: 02070414A1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR07MB0805; 23:kutSB0A0dln/xwvWWwc0VZNrOTfws3VGCIjvOZviY?= 0AEUZumDeWX190vWF8Of6BwSPTXuacD6+nlowDf0f+rXpy/sIUGFqoDeuUU/v6U7krL46jV5x8brC9hwJRrXEU+8Dse5aM21dHTzlGlA86tz+/UtXGt2piijAo0LyeE7ALiKY1UnvfbDgldD2rue/ztBV58pnAucO6y/8lBdXHwUPKvPVVpnhh/oxA7Hxzn3Cr6YH+/8JnNGjzh76DHCfh8WIPc4+InFw9ZHXSWEdEs9dntLrMwApkMHVgM7OuLXbDRlWmOM8WMeqptPFJEHw52c1f1Nx7ikby5T6VQ+lPNzI5WT/GTSu2swuBPp71WIRj03XLk4P6bRxPYZQ5jIL5/DCMTQupo8KkxRyPcQo05m3ovTc1YJR7epOFuN3OZUKwiw2/jTetGHzapGYR+I6Zy83F4Yt5BBeku97yY1O5PoHeYvixkm0U9fNjVf9G/n+TlAXXjeNCOiuT49+je/Eja5OgyskvqVgnn4ZrzkM6ufKMSO7TDzgODT3Vsu//WYru+Yd2F+htN5jUfF8gDZ11RPmdfdM8WxauIj6PwNYADYOEMKrXT1aqxNdjC/fXZ/0azuyCwZQkdpUG6vGtgHIQREbY2wzuHCG+n4sg2nR1IclDkAztZnxOSt2adZx+1DvtCIa2ELaCCDIdqOXXughIdRRaqu6L0YU9+L82O2Tvdwh4I9rpkYbNisSa/cBJegbvTxvfDo9liSQQh9ttMBpSypUNuepI1MQMGgj8lOUXAmhCRa5qHV+24vY6TjFpI447Xz+NQnS65rLEyYBctwptd4KiVAtF5/NSccKgXnZ6ZgU+u2R6y04fxBMkNL3WD50/uNWoBA0xcwhDXuVpqSgZC8zFnqVRpUB0XSfsoL3oQdcxzhHyTj6YGg4d2DU6eWIGEJ6qrpCfY2F0kjbLhULWr+ycOYeygbFwiKr50ZHtt3TJRgLdi9f+O0UTrD2kO2BKAXyW1qBWq92DN2AXUZnnXbrbG+P3N6oMclbOK3Wx5T+1ksxPneNrQIWXQVa6Wc1t3DRcvGOP1SHi0qr2ogwJA1gW+K1dQdtUj3Dd99WAle1kv+WfJMlk1UMyY542u8IFpm/u3sdPt1tSxiO0izaHg X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0805; 6:OrN8Y2RUWMLbSIsuDGAHEo4tH8MqeItxCeJNC3JZbGsn5YwuLF2KkA+X6AiBR3eA0g7yV7YWm7ODClpwhxJdQ4DYlQIOmCLqoBJyCrvA+EkLBt7+o0EaYQzZoHG76YPqGD93CqmoWPCI/Ct6qfHD4s/5Z48n2GVpkbv0tdWFz+APHp8sXvsKC8wU2/+9Jj3wIgru/KlJZK27oCrSariNAL3B9qyH866Oh6Cl7laj22d0sbwDgTURPapBi5CksfGtANwKmLeau+eM+V4n11yV5N+h27qCqCRTFzLg1c132LoeNLPtn10Iu6uIuTX8kBbTOP4I5/puQ7Cp3Lv5LtRZMolm2tOmPbfoQAmeaPqxpoCizsjjKNfFU1qPRp0b/rOITZJda0R2V+6Ghv8OfMv1LA==; 5:FtHVxP3G8eMXViSPQubGY69Xn4q5s1CYot7ZrakusKpc4PJ0Te34PXpDh+1F0zcoBS/OkVB4scuq4wUTekHWPerFuE00nYHogaZCUrz1cOqD9D6wCu97zu7Q3uSGUSGHQ8nVxrdkdR/BaIck6aIhGQ==; 24:zDskkI8/+cc/Ruc8r/NiKQig+YyXJqpJYJo84EqrNBj7P0WkAtUBWSKnSpqJvr9qm0smyefkhqaBR5WHSokEq3By2EVeIF5nTWKkivlgxwY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0805; 7:uNEm1fWi5AZrvOPlArwMDdm058TMKnHlUv62ZNTVeLUQTAqB9ApudfYYfESfJXB2rFyfa/6RauBy3dylPUkDkKP71mnPnilN84d5M8vv4lbtW60JJWrmRedfX/fdtQDhnZZ7sTQ6R3fjAzURIJnWaU/l3YYRM0azLFAzi/qi2j8qnw1VtJ4vnHZRM6WzyVLMM8Qme6F7RLQZbC6tVroxDz5O+kyErBKlwKXshGrWdHv37PznCKy5YYSC+OkZCAOVyr4nqkjIiPB37xo4u06jNxb+m7nRl+QmWr5YZiUJXJ+Td79ACTNIUIRaOoWycV8BX8z+a6FhxSiIMo06i65qUH5ZIN9PTH1fmAVzEJrbvLA99BmEcCgGhPWqOaki24COAqcUl07cCm9b284vWbv5ANsW0C8HTsMSM9mskYXtHqziSFrWcRwzEo64BYyrvwI2NS6sWsz8LHdncu2m0xJRV+zH4Tl5hzNFvMVpy7rqOz01XJM7iZ8J5PNegyMYyAZbxNvohbE++Y19k2/pMNtFZQ== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2017 11:24:28.7125 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.35]; Helo=[hybrid2.ext.net.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB0805 Subject: [lng-odp] [PATCH 1/2] helper: linux: renamed threads_extn to linux helpers X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" There's no platform specific helpers. Helpers may depend on Linux and make it easier to do common series of Linux system calls. These kind of helpers are grouped into helper/linux directory. Use --enable-helper-linux configuration option to enable support for Linux helpers. Signed-off-by: Petri Savolainen --- configure.ac | 17 +- example/Makefile.inc | 2 +- helper/Makefile.am | 18 +- helper/include/odp/helper/linux/process.h | 84 ++++++ helper/include/odp/helper/linux/pthread.h | 66 +++++ .../helper/platform/linux-generic/threads_extn.h | 112 -------- helper/linux/thread.c | 239 ++++++++++++++++ helper/m4/configure.m4 | 8 +- helper/platform/linux-generic/thread.c | 313 --------------------- helper/test/.gitignore | 1 + helper/test/Makefile.am | 9 +- helper/test/linux-generic/Makefile.am | 5 - helper/test/linux-generic/process.c | 92 ------ helper/test/linux-generic/thread.c | 87 ------ helper/test/linux/Makefile.am | 5 + helper/test/linux/process.c | 93 ++++++ helper/test/linux/pthread.c | 87 ++++++ test/Makefile.inc | 2 +- test/common_plat/validation/api/Makefile.inc | 2 +- test/linux-generic/Makefile.inc | 2 +- 20 files changed, 599 insertions(+), 645 deletions(-) create mode 100644 helper/include/odp/helper/linux/process.h create mode 100644 helper/include/odp/helper/linux/pthread.h delete mode 100644 helper/include/odp/helper/platform/linux-generic/threads_extn.h create mode 100644 helper/linux/thread.c delete mode 100644 helper/platform/linux-generic/thread.c delete mode 100644 helper/test/linux-generic/Makefile.am delete mode 100644 helper/test/linux-generic/process.c delete mode 100644 helper/test/linux-generic/thread.c create mode 100644 helper/test/linux/Makefile.am create mode 100644 helper/test/linux/process.c create mode 100644 helper/test/linux/pthread.c -- 2.8.1 Reviewed-by: Mike Holmes Signed-off-by: Petri Savolainen Reviewed-by: Mike Holmes Signed-off-by: Petri Savolainen Reviewed-by: Mike Holmes diff --git a/configure.ac b/configure.ac index daa9b31..b672a1a 100644 --- a/configure.ac +++ b/configure.ac @@ -138,18 +138,6 @@ AC_SUBST([with_platform]) AC_SUBST([platform_with_platform], ["platform/${with_platform}"]) ########################################################################## -# Determine which helper platform to build for -########################################################################## -AC_ARG_WITH([helper_platform], - [AS_HELP_STRING([--with-helper_platform=platform], - [select helper platform to be used, default linux-generic])], - [], - [with_helper_platform=${with_platform} - ]) - -AC_SUBST([with_helper_platform]) - -########################################################################## # Run platform specific checks and settings ########################################################################## IMPLEMENTATION_NAME="" @@ -214,7 +202,7 @@ AM_CONDITIONAL([test_example], [test x$test_example = xyes ]) AM_CONDITIONAL([HAVE_DOXYGEN], [test "x${DOXYGEN}" = "xdoxygen"]) AM_CONDITIONAL([user_guide], [test "x${user_guides}" = "xyes" ]) AM_CONDITIONAL([HAVE_MSCGEN], [test "x${MSCGEN}" = "xmscgen"]) -AM_CONDITIONAL([helper_extn], [test x$helper_extn = xyes ]) +AM_CONDITIONAL([helper_linux], [test x$helper_linux = xyes ]) ########################################################################## # Setup doxygen documentation @@ -345,8 +333,7 @@ AC_MSG_RESULT([ implementation_name: ${IMPLEMENTATION_NAME} ARCH_DIR ${ARCH_DIR} with_platform: ${with_platform} - with_helper_platform: ${with_helper_platform} - helper_extn: ${helper_extn} + helper_linux: ${helper_linux} prefix: ${prefix} sysconfdir: ${sysconfdir} libdir: ${libdir} diff --git a/example/Makefile.inc b/example/Makefile.inc index ea596d5..70e3758 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -1,6 +1,6 @@ include $(top_srcdir)/platform/@with_platform@/Makefile.inc LIB = $(top_builddir)/lib -LDADD = $(LIB)/libodp-linux.la $(LIB)/libodphelper-@with_helper_platform@.la +LDADD = $(LIB)/libodp-linux.la $(LIB)/libodphelper.la AM_CFLAGS += \ -I$(srcdir) \ -I$(top_srcdir)/example \ diff --git a/helper/Makefile.am b/helper/Makefile.am index d484679..9b6e3ce 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -30,16 +30,18 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/threads.h \ $(srcdir)/include/odp/helper/udp.h -if helper_extn -helperinclude_HEADERS += \ - $(srcdir)/include/odp/helper/platform/@with_helper_platform@/threads_extn.h +if helper_linux +helperlinuxincludedir = $(includedir)/odp/helper/linux +helperlinuxinclude_HEADERS = \ + $(srcdir)/include/odp/helper/linux/pthread.h \ + $(srcdir)/include/odp/helper/linux/process.h endif noinst_HEADERS = \ $(srcdir)/odph_debug.h \ $(srcdir)/odph_list_internal.h -__LIB__libodphelper_@with_platform@_la_SOURCES = \ +__LIB__libodphelper_la_SOURCES = \ eth.c \ ip.c \ chksum.c \ @@ -49,9 +51,9 @@ __LIB__libodphelper_@with_platform@_la_SOURCES = \ iplookuptable.c \ threads.c -if helper_extn -__LIB__libodphelper_@with_platform@_la_SOURCES += \ - platform/@with_helper_platform@/thread.c +if helper_linux +__LIB__libodphelper_la_SOURCES += \ + linux/thread.c endif -lib_LTLIBRARIES = $(LIB)/libodphelper-@with_platform@.la +lib_LTLIBRARIES = $(LIB)/libodphelper.la diff --git a/helper/include/odp/helper/linux/process.h b/helper/include/odp/helper/linux/process.h new file mode 100644 index 0000000..9d74146 --- /dev/null +++ b/helper/include/odp/helper/linux/process.h @@ -0,0 +1,84 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Linux helper for processes + * + * This file is not part of ODP APIs, but can be optionally used to ease common + * setups in a Linux system. User is free to implement the same setups in + * otherways (not via this file). + */ + +#ifndef ODPH_LINUX_PROCESS_H_ +#define ODPH_LINUX_PROCESS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup odph_linux + * @{ + */ + +/** + * Fork a process + * + * Forks and sets CPU affinity for the child process. Ignores 'start' and 'arg' + * thread parameters. + * + * @param[out] proc Pointer to process state info (for output) + * @param cpu Destination CPU for the child process + * @param thr_params Linux helper thread parameters + * + * @return On success: 1 for the parent, 0 for the child + * On failure: -1 for the parent, -2 for the child + */ +int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, + const odph_linux_thr_params_t *thr_params); + +/** + * Fork a number of processes + * + * Forks and sets CPU affinity for child processes. Ignores 'start' and 'arg' + * thread parameters. + * + * @param[out] proc_tbl Process state info table (for output) + * @param mask CPU mask of processes to create + * @param thr_params Linux helper thread parameters + * + * @return On success: 1 for the parent, 0 for the child + * On failure: -1 for the parent, -2 for the child + */ +int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, + const odp_cpumask_t *mask, + const odph_linux_thr_params_t *thr_params); + +/** + * Wait for a number of processes + * + * Waits for a number of child processes to terminate. Records process state + * change status into the process state info structure. + * + * @param proc_tbl Process state info table (previously filled by fork) + * @param num Number of processes to wait + * + * @return 0 on success, -1 on failure + */ +int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/include/odp/helper/linux/pthread.h b/helper/include/odp/helper/linux/pthread.h new file mode 100644 index 0000000..feeda5e --- /dev/null +++ b/helper/include/odp/helper/linux/pthread.h @@ -0,0 +1,66 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Linux helper for pthreads + * + * This file is not part of ODP APIs, but can be optionally used to ease common + * setups in a Linux system. User is free to implement the same setups in + * otherways (not via this file). + */ + +#ifndef ODPH_LINUX_PTHREAD_H_ +#define ODPH_LINUX_PTHREAD_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup odph_linux + * @{ + */ + +/** + * Creates and launches pthreads + * + * Creates, pins and launches threads to separate CPU's based on the cpumask. + * + * @param[out] pthread_tbl Table of pthread state information records. Table + * must have at least as many entries as there are + * CPUs in the CPU mask. + * @param mask CPU mask + * @param thr_params Linux helper thread parameters + * + * @return Number of threads created + */ +int odph_linux_pthread_create(odph_linux_pthread_t *pthread_tbl, + const odp_cpumask_t *mask, + const odph_linux_thr_params_t *thr_params); + +/** + * Waits pthreads to exit + * + * Returns when all threads have been exit. + * + * @param thread_tbl Thread table + * @param num Number of threads to create + * + */ +void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/include/odp/helper/platform/linux-generic/threads_extn.h b/helper/include/odp/helper/platform/linux-generic/threads_extn.h deleted file mode 100644 index 1d4036d..0000000 --- a/helper/include/odp/helper/platform/linux-generic/threads_extn.h +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP Linux helper extension API - * - * This file is an optional helper to odp.h APIs. These functions are provided - * to ease common setups in a Linux system. User is free to implement the same - * setups in otherways (not via this API). - */ - -#ifndef ODPH_LINUX_EXT_H_ -#define ODPH_LINUX_EXT_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odph_linux ODPH LINUX - * @{ - */ - -/** - * Creates and launches pthreads - * - * Creates, pins and launches threads to separate CPU's based on the cpumask. - * - * @param[out] pthread_tbl Table of pthread state information records. Table - * must have at least as many entries as there are - * CPUs in the CPU mask. - * @param mask CPU mask - * @param thr_params Linux helper thread parameters - * - * @return Number of threads created - */ -int odph_linux_pthread_create(odph_linux_pthread_t *pthread_tbl, - const odp_cpumask_t *mask, - const odph_linux_thr_params_t *thr_params); - -/** - * Waits pthreads to exit - * - * Returns when all threads have been exit. - * - * @param thread_tbl Thread table - * @param num Number of threads to create - * - */ -void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num); - -/** - * Fork a process - * - * Forks and sets CPU affinity for the child process. Ignores 'start' and 'arg' - * thread parameters. - * - * @param[out] proc Pointer to process state info (for output) - * @param cpu Destination CPU for the child process - * @param thr_params Linux helper thread parameters - * - * @return On success: 1 for the parent, 0 for the child - * On failure: -1 for the parent, -2 for the child - */ -int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, - const odph_linux_thr_params_t *thr_params); - -/** - * Fork a number of processes - * - * Forks and sets CPU affinity for child processes. Ignores 'start' and 'arg' - * thread parameters. - * - * @param[out] proc_tbl Process state info table (for output) - * @param mask CPU mask of processes to create - * @param thr_params Linux helper thread parameters - * - * @return On success: 1 for the parent, 0 for the child - * On failure: -1 for the parent, -2 for the child - */ -int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, - const odp_cpumask_t *mask, - const odph_linux_thr_params_t *thr_params); - -/** - * Wait for a number of processes - * - * Waits for a number of child processes to terminate. Records process state - * change status into the process state info structure. - * - * @param proc_tbl Process state info table (previously filled by fork) - * @param num Number of processes to wait - * - * @return 0 on success, -1 on failure - */ -int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/helper/linux/thread.c b/helper/linux/thread.c new file mode 100644 index 0000000..52d4efc --- /dev/null +++ b/helper/linux/thread.c @@ -0,0 +1,239 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include "odph_debug.h" + +static void *_odph_run_start_routine(void *arg) +{ + odph_linux_thr_params_t *thr_params = arg; + + /* ODP thread local init */ + if (odp_init_local(thr_params->instance, thr_params->thr_type)) { + ODPH_ERR("Local init failed\n"); + return NULL; + } + + void *ret_ptr = thr_params->start(thr_params->arg); + int ret = odp_term_local(); + + if (ret < 0) + ODPH_ERR("Local term failed\n"); + + return ret_ptr; +} + +int odph_linux_pthread_create(odph_linux_pthread_t *pthread_tbl, + const odp_cpumask_t *mask, + const odph_linux_thr_params_t *thr_params) +{ + int i; + int num; + int cpu_count; + int cpu; + int ret; + + num = odp_cpumask_count(mask); + + memset(pthread_tbl, 0, num * sizeof(odph_linux_pthread_t)); + + cpu_count = odp_cpu_count(); + + if (num < 1 || num > cpu_count) { + ODPH_ERR("Invalid number of threads:%d (%d cores available)\n", + num, cpu_count); + return 0; + } + + cpu = odp_cpumask_first(mask); + for (i = 0; i < num; i++) { + cpu_set_t cpu_set; + + CPU_ZERO(&cpu_set); + CPU_SET(cpu, &cpu_set); + + pthread_attr_init(&pthread_tbl[i].attr); + + pthread_tbl[i].cpu = cpu; + + pthread_attr_setaffinity_np(&pthread_tbl[i].attr, + sizeof(cpu_set_t), &cpu_set); + + pthread_tbl[i].thr_params.start = thr_params->start; + pthread_tbl[i].thr_params.arg = thr_params->arg; + pthread_tbl[i].thr_params.thr_type = thr_params->thr_type; + pthread_tbl[i].thr_params.instance = thr_params->instance; + + ret = pthread_create(&pthread_tbl[i].thread, + &pthread_tbl[i].attr, + _odph_run_start_routine, + &pthread_tbl[i].thr_params); + if (ret != 0) { + ODPH_ERR("Failed to start thread on cpu #%d\n", cpu); + break; + } + + cpu = odp_cpumask_next(mask, cpu); + } + + return i; +} + +void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num) +{ + int i; + int ret; + + for (i = 0; i < num; i++) { + /* Wait thread to exit */ + ret = pthread_join(thread_tbl[i].thread, NULL); + if (ret != 0) { + ODPH_ERR("Failed to join thread from cpu #%d\n", + thread_tbl[i].cpu); + } + pthread_attr_destroy(&thread_tbl[i].attr); + } +} + +int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, + const odp_cpumask_t *mask, + const odph_linux_thr_params_t *thr_params) +{ + pid_t pid; + int num; + int cpu_count; + int cpu; + int i; + + num = odp_cpumask_count(mask); + + memset(proc_tbl, 0, num * sizeof(odph_linux_process_t)); + + cpu_count = odp_cpu_count(); + + if (num < 1 || num > cpu_count) { + ODPH_ERR("Bad num\n"); + return -1; + } + + cpu = odp_cpumask_first(mask); + for (i = 0; i < num; i++) { + cpu_set_t cpu_set; + + CPU_ZERO(&cpu_set); + CPU_SET(cpu, &cpu_set); + + pid = fork(); + + if (pid < 0) { + ODPH_ERR("fork() failed\n"); + return -1; + } + + /* Parent continues to fork */ + if (pid > 0) { + proc_tbl[i].pid = pid; + proc_tbl[i].cpu = cpu; + + cpu = odp_cpumask_next(mask, cpu); + continue; + } + + /* Child process */ + + /* Request SIGTERM if parent dies */ + prctl(PR_SET_PDEATHSIG, SIGTERM); + /* Parent died already? */ + if (getppid() == 1) + kill(getpid(), SIGTERM); + + if (sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set)) { + ODPH_ERR("sched_setaffinity() failed\n"); + return -2; + } + + if (odp_init_local(thr_params->instance, + thr_params->thr_type)) { + ODPH_ERR("Local init failed\n"); + return -2; + } + + return 0; + } + + return 1; +} + +int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, + const odph_linux_thr_params_t *thr_params) +{ + odp_cpumask_t mask; + + odp_cpumask_zero(&mask); + odp_cpumask_set(&mask, cpu); + return odph_linux_process_fork_n(proc, &mask, thr_params); +} + +int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num) +{ + pid_t pid; + int i, j; + int status = 0; + + for (i = 0; i < num; i++) { + pid = wait(&status); + + if (pid < 0) { + ODPH_ERR("wait() failed\n"); + return -1; + } + + for (j = 0; j < num; j++) { + if (proc_tbl[j].pid == pid) { + proc_tbl[j].status = status; + break; + } + } + + if (j == num) { + ODPH_ERR("Bad pid:%d\n", (int)pid); + return -1; + } + + /* Examine the child process' termination status */ + if (WIFEXITED(status) && WEXITSTATUS(status) != EXIT_SUCCESS) { + ODPH_ERR("Child exit status:%d (pid:%d)\n", + WEXITSTATUS(status), (int)pid); + return -1; + } + if (WIFSIGNALED(status)) { + int signo = WTERMSIG(status); + + ODPH_ERR("Child term signo:%d - %s (pid:%d)\n", + signo, strsignal(signo), (int)pid); + return -1; + } + } + + return 0; +} diff --git a/helper/m4/configure.m4 b/helper/m4/configure.m4 index 38c95d9..343f5e3 100644 --- a/helper/m4/configure.m4 +++ b/helper/m4/configure.m4 @@ -12,11 +12,11 @@ AC_ARG_ENABLE([test-helper], # Enable/disable helper-ext # platform specific non portable extensions ########################################################################## -helper_extn=no -AC_ARG_ENABLE([helper-extn], - [ --enable-helper-extn build helper platform extensions (not portable)], +helper_linux=no +AC_ARG_ENABLE([helper-linux], + [ --enable-helper-linux build helper platform extensions (not portable)], [if test "x$enableval" = "xyes"; then - helper_extn=yes + helper_linux=yes fi]) AC_CONFIG_FILES([helper/Makefile diff --git a/helper/platform/linux-generic/thread.c b/helper/platform/linux-generic/thread.c deleted file mode 100644 index 90fa42a..0000000 --- a/helper/platform/linux-generic/thread.c +++ /dev/null @@ -1,313 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include "odph_debug.h" - -static void *_odph_run_start_routine(void *arg) -{ - odph_linux_thr_params_t *thr_params = arg; - - /* ODP thread local init */ - if (odp_init_local(thr_params->instance, thr_params->thr_type)) { - ODPH_ERR("Local init failed\n"); - return NULL; - } - - void *ret_ptr = thr_params->start(thr_params->arg); - int ret = odp_term_local(); - - if (ret < 0) - ODPH_ERR("Local term failed\n"); - - return ret_ptr; -} - -static void *_odph_thread_run_start_routine(void *arg) -{ - int status; - int ret; - odph_odpthread_params_t *thr_params; - - odph_odpthread_start_args_t *start_args = arg; - - thr_params = &start_args->thr_params; - - /* ODP thread local init */ - if (odp_init_local(thr_params->instance, thr_params->thr_type)) { - ODPH_ERR("Local init failed\n"); - if (start_args->linuxtype == ODPTHREAD_PROCESS) - _exit(EXIT_FAILURE); - return (void *)-1; - } - - ODPH_DBG("helper: ODP %s thread started as linux %s. (pid=%d)\n", - thr_params->thr_type == ODP_THREAD_WORKER ? - "worker" : "control", - (start_args->linuxtype == ODPTHREAD_PTHREAD) ? - "pthread" : "process", - (int)getpid()); - - status = thr_params->start(thr_params->arg); - ret = odp_term_local(); - - if (ret < 0) - ODPH_ERR("Local term failed\n"); - - /* for process implementation of odp threads, just return status... */ - if (start_args->linuxtype == ODPTHREAD_PROCESS) - _exit(status); - - /* threads implementation return void* pointers: cast status to that. */ - return (void *)(intptr_t)status; -} - -int odph_linux_pthread_create(odph_linux_pthread_t *pthread_tbl, - const odp_cpumask_t *mask, - const odph_linux_thr_params_t *thr_params) -{ - int i; - int num; - int cpu_count; - int cpu; - int ret; - - num = odp_cpumask_count(mask); - - memset(pthread_tbl, 0, num * sizeof(odph_linux_pthread_t)); - - cpu_count = odp_cpu_count(); - - if (num < 1 || num > cpu_count) { - ODPH_ERR("Invalid number of threads:%d (%d cores available)\n", - num, cpu_count); - return 0; - } - - cpu = odp_cpumask_first(mask); - for (i = 0; i < num; i++) { - cpu_set_t cpu_set; - - CPU_ZERO(&cpu_set); - CPU_SET(cpu, &cpu_set); - - pthread_attr_init(&pthread_tbl[i].attr); - - pthread_tbl[i].cpu = cpu; - - pthread_attr_setaffinity_np(&pthread_tbl[i].attr, - sizeof(cpu_set_t), &cpu_set); - - pthread_tbl[i].thr_params.start = thr_params->start; - pthread_tbl[i].thr_params.arg = thr_params->arg; - pthread_tbl[i].thr_params.thr_type = thr_params->thr_type; - pthread_tbl[i].thr_params.instance = thr_params->instance; - - ret = pthread_create(&pthread_tbl[i].thread, - &pthread_tbl[i].attr, - _odph_run_start_routine, - &pthread_tbl[i].thr_params); - if (ret != 0) { - ODPH_ERR("Failed to start thread on cpu #%d\n", cpu); - break; - } - - cpu = odp_cpumask_next(mask, cpu); - } - - return i; -} - -void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num) -{ - int i; - int ret; - - for (i = 0; i < num; i++) { - /* Wait thread to exit */ - ret = pthread_join(thread_tbl[i].thread, NULL); - if (ret != 0) { - ODPH_ERR("Failed to join thread from cpu #%d\n", - thread_tbl[i].cpu); - } - pthread_attr_destroy(&thread_tbl[i].attr); - } -} - -int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, - const odp_cpumask_t *mask, - const odph_linux_thr_params_t *thr_params) -{ - pid_t pid; - int num; - int cpu_count; - int cpu; - int i; - - num = odp_cpumask_count(mask); - - memset(proc_tbl, 0, num * sizeof(odph_linux_process_t)); - - cpu_count = odp_cpu_count(); - - if (num < 1 || num > cpu_count) { - ODPH_ERR("Bad num\n"); - return -1; - } - - cpu = odp_cpumask_first(mask); - for (i = 0; i < num; i++) { - cpu_set_t cpu_set; - - CPU_ZERO(&cpu_set); - CPU_SET(cpu, &cpu_set); - - pid = fork(); - - if (pid < 0) { - ODPH_ERR("fork() failed\n"); - return -1; - } - - /* Parent continues to fork */ - if (pid > 0) { - proc_tbl[i].pid = pid; - proc_tbl[i].cpu = cpu; - - cpu = odp_cpumask_next(mask, cpu); - continue; - } - - /* Child process */ - - /* Request SIGTERM if parent dies */ - prctl(PR_SET_PDEATHSIG, SIGTERM); - /* Parent died already? */ - if (getppid() == 1) - kill(getpid(), SIGTERM); - - if (sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set)) { - ODPH_ERR("sched_setaffinity() failed\n"); - return -2; - } - - if (odp_init_local(thr_params->instance, - thr_params->thr_type)) { - ODPH_ERR("Local init failed\n"); - return -2; - } - - return 0; - } - - return 1; -} - -int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, - const odph_linux_thr_params_t *thr_params) -{ - odp_cpumask_t mask; - - odp_cpumask_zero(&mask); - odp_cpumask_set(&mask, cpu); - return odph_linux_process_fork_n(proc, &mask, thr_params); -} - -int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num) -{ - pid_t pid; - int i, j; - int status = 0; - - for (i = 0; i < num; i++) { - pid = wait(&status); - - if (pid < 0) { - ODPH_ERR("wait() failed\n"); - return -1; - } - - for (j = 0; j < num; j++) { - if (proc_tbl[j].pid == pid) { - proc_tbl[j].status = status; - break; - } - } - - if (j == num) { - ODPH_ERR("Bad pid:%d\n", (int)pid); - return -1; - } - - /* Examine the child process' termination status */ - if (WIFEXITED(status) && WEXITSTATUS(status) != EXIT_SUCCESS) { - ODPH_ERR("Child exit status:%d (pid:%d)\n", - WEXITSTATUS(status), (int)pid); - return -1; - } - if (WIFSIGNALED(status)) { - int signo = WTERMSIG(status); - - ODPH_ERR("Child term signo:%d - %s (pid:%d)\n", - signo, strsignal(signo), (int)pid); - return -1; - } - } - - return 0; -} - -/* - * Create a single ODPthread as a linux thread - */ -static int odph_linux_thread_create(odph_odpthread_t *thread_tbl, - int cpu, - const odph_odpthread_params_t *thr_params) -{ - int ret; - cpu_set_t cpu_set; - - CPU_ZERO(&cpu_set); - CPU_SET(cpu, &cpu_set); - - pthread_attr_init(&thread_tbl->thread.attr); - - thread_tbl->cpu = cpu; - - pthread_attr_setaffinity_np(&thread_tbl->thread.attr, - sizeof(cpu_set_t), &cpu_set); - - thread_tbl->start_args.thr_params = *thr_params; /* copy */ - thread_tbl->start_args.linuxtype = ODPTHREAD_PTHREAD; - - ret = pthread_create(&thread_tbl->thread.thread_id, - &thread_tbl->thread.attr, - _odph_thread_run_start_routine, - &thread_tbl->start_args); - if (ret != 0) { - ODPH_ERR("Failed to start thread on cpu #%d\n", cpu); - thread_tbl->start_args.linuxtype = ODPTHREAD_NOT_STARTED; - return ret; - } - - return 0; -} diff --git a/helper/test/.gitignore b/helper/test/.gitignore index e5b6a0f..1a81e00 100644 --- a/helper/test/.gitignore +++ b/helper/test/.gitignore @@ -8,3 +8,4 @@ parse process table thread +pthread diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am index 1c50282..99b6df8 100644 --- a/helper/test/Makefile.am +++ b/helper/test/Makefile.am @@ -5,12 +5,11 @@ LIB = $(top_builddir)/lib #in the following line, the libs using the symbols should come before #the libs containing them! The includer is given a chance to add things #before libodp by setting PRE_LDADD before the inclusion. -LDADD = $(PRE_LDADD) $(LIB)/libodphelper-@with_helper_platform@.la $(LIB)/libodp-linux.la +LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp-linux.la INCFLAGS = \ -I$(top_builddir)/platform/@with_platform@/include \ -I$(top_srcdir)/helper/include \ - -I$(top_srcdir)/helper/platform/@with_helper_platform@/include \ -I$(top_srcdir)/include \ -I$(top_srcdir)/platform/@with_platform@/include \ -I$(top_builddir)/include \ @@ -31,9 +30,9 @@ EXECUTABLES = chksum$(EXEEXT) \ #They are a convenience to app writers who have chosen to #restrict their application to Linux. -if helper_extn -EXECUTABLES += @with_helper_platform@/thread$(EXEEXT) \ - @with_helper_platform@/process$(EXEEXT) +if helper_linux +EXECUTABLES += linux/pthread$(EXEEXT) \ + linux/process$(EXEEXT) endif COMPILE_ONLY = odpthreads diff --git a/helper/test/linux-generic/Makefile.am b/helper/test/linux-generic/Makefile.am deleted file mode 100644 index 28d54a8..0000000 --- a/helper/test/linux-generic/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ - -thread_LDADD = $(LIB)/libodphelper-@with_helper_platform@.la $(LIB)/libodp-linux.la -dist_thread_SOURCES = thread.c -dist_process_SOURCES = process.c -process_LDADD = $(LIB)/libodphelper-@with_helper_platform@.la $(LIB)/libodp-linux.la diff --git a/helper/test/linux-generic/process.c b/helper/test/linux-generic/process.c deleted file mode 100644 index f9bdc3e..0000000 --- a/helper/test/linux-generic/process.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include - -#define NUMBER_WORKERS 16 /* 0 = max */ - -static void *worker_fn(void *arg ODPH_UNUSED) -{ - /* depend on the odp helper to call odp_init_local */ - printf("Worker thread on CPU %d\n", odp_cpu_id()); - - return 0; -} - -/* Create additional dataplane processes */ -int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) -{ - odp_cpumask_t cpu_mask; - int num_workers; - int cpu; - char cpumaskstr[ODP_CPUMASK_STR_SIZE]; - int ret; - odph_linux_process_t proc[NUMBER_WORKERS]; - odp_instance_t instance; - odph_linux_thr_params_t thr_params; - - if (odp_init_global(&instance, NULL, NULL)) { - ODPH_ERR("Error: ODP global init failed.\n"); - exit(EXIT_FAILURE); - } - - if (odp_init_local(instance, ODP_THREAD_CONTROL)) { - ODPH_ERR("Error: ODP local init failed.\n"); - exit(EXIT_FAILURE); - } - - /* discover how many processes this system can support */ - num_workers = odp_cpumask_default_worker(&cpu_mask, NUMBER_WORKERS); - if (num_workers < NUMBER_WORKERS) { - printf("System can only support %d processes and not the %d requested\n", - num_workers, NUMBER_WORKERS); - } - - /* generate a summary for the user */ - (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); - printf("default cpu mask: %s\n", cpumaskstr); - printf("default num worker processes: %i\n", num_workers); - - cpu = odp_cpumask_first(&cpu_mask); - printf("the first CPU: %i\n", cpu); - - /* reserve cpu 0 for the control plane so remove it from - * the default mask */ - odp_cpumask_clr(&cpu_mask, 0); - num_workers = odp_cpumask_count(&cpu_mask); - (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); - printf("new cpu mask: %s\n", cpumaskstr); - printf("new num worker processes: %i\n\n", num_workers); - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; - - /* Fork worker processes */ - ret = odph_linux_process_fork_n(proc, &cpu_mask, &thr_params); - - if (ret < 0) { - ODPH_ERR("Fork workers failed %i\n", ret); - return -1; - } - - if (ret == 0) { - /* Child process */ - worker_fn(NULL); - } else { - /* Parent process */ - odph_linux_process_wait_n(proc, num_workers); - - if (odp_term_global(instance)) { - ODPH_ERR("Error: ODP global term failed.\n"); - exit(EXIT_FAILURE); - } - } - - return 0; -} diff --git a/helper/test/linux-generic/thread.c b/helper/test/linux-generic/thread.c deleted file mode 100644 index 919f00e..0000000 --- a/helper/test/linux-generic/thread.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include - -#define NUMBER_WORKERS 16 -static void *worker_fn(void *arg ODPH_UNUSED) -{ - /* depend on the odp helper to call odp_init_local */ - - printf("Worker thread on CPU %d\n", odp_cpu_id()); - - /* depend on the odp helper to call odp_term_local */ - - return NULL; -} - -/* Create additional dataplane threads */ -int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) -{ - odph_linux_pthread_t thread_tbl[NUMBER_WORKERS]; - odp_cpumask_t cpu_mask; - int num_workers; - int cpu; - char cpumaskstr[ODP_CPUMASK_STR_SIZE]; - odp_instance_t instance; - odph_linux_thr_params_t thr_params; - - if (odp_init_global(&instance, NULL, NULL)) { - ODPH_ERR("Error: ODP global init failed.\n"); - exit(EXIT_FAILURE); - } - - if (odp_init_local(instance, ODP_THREAD_CONTROL)) { - ODPH_ERR("Error: ODP local init failed.\n"); - exit(EXIT_FAILURE); - } - - /* discover how many threads this system can support */ - num_workers = odp_cpumask_default_worker(&cpu_mask, NUMBER_WORKERS); - if (num_workers < NUMBER_WORKERS) { - printf("System can only support %d threads and not the %d requested\n", - num_workers, NUMBER_WORKERS); - } - - /* generate a summary for the user */ - (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); - printf("default cpu mask: %s\n", cpumaskstr); - printf("default num worker threads: %i\n", num_workers); - - cpu = odp_cpumask_first(&cpu_mask); - printf("the first CPU: %i\n", cpu); - - /* reserve cpu 0 for the control plane so remove it from - * the default mask */ - odp_cpumask_clr(&cpu_mask, 0); - num_workers = odp_cpumask_count(&cpu_mask); - (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); - printf("new cpu mask: %s\n", cpumaskstr); - printf("new num worker threads: %i\n\n", num_workers); - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.start = worker_fn; - thr_params.arg = NULL; - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; - - odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, &thr_params); - odph_linux_pthread_join(thread_tbl, num_workers); - - if (odp_term_local()) { - ODPH_ERR("Error: ODP local term failed.\n"); - exit(EXIT_FAILURE); - } - - if (odp_term_global(instance)) { - ODPH_ERR("Error: ODP global term failed.\n"); - exit(EXIT_FAILURE); - } - - return 0; -} diff --git a/helper/test/linux/Makefile.am b/helper/test/linux/Makefile.am new file mode 100644 index 0000000..f95e04d --- /dev/null +++ b/helper/test/linux/Makefile.am @@ -0,0 +1,5 @@ + +thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la +dist_thread_SOURCES = pthread.c +dist_process_SOURCES = process.c +process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la diff --git a/helper/test/linux/process.c b/helper/test/linux/process.c new file mode 100644 index 0000000..e08ef86 --- /dev/null +++ b/helper/test/linux/process.c @@ -0,0 +1,93 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +#define NUMBER_WORKERS 16 /* 0 = max */ + +static void *worker_fn(void *arg ODPH_UNUSED) +{ + /* depend on the odp helper to call odp_init_local */ + printf("Worker thread on CPU %d\n", odp_cpu_id()); + + return 0; +} + +/* Create additional dataplane processes */ +int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) +{ + odp_cpumask_t cpu_mask; + int num_workers; + int cpu; + char cpumaskstr[ODP_CPUMASK_STR_SIZE]; + int ret; + odph_linux_process_t proc[NUMBER_WORKERS]; + odp_instance_t instance; + odph_linux_thr_params_t thr_params; + + if (odp_init_global(&instance, NULL, NULL)) { + ODPH_ERR("Error: ODP global init failed.\n"); + exit(EXIT_FAILURE); + } + + if (odp_init_local(instance, ODP_THREAD_CONTROL)) { + ODPH_ERR("Error: ODP local init failed.\n"); + exit(EXIT_FAILURE); + } + + /* discover how many processes this system can support */ + num_workers = odp_cpumask_default_worker(&cpu_mask, NUMBER_WORKERS); + if (num_workers < NUMBER_WORKERS) { + printf("System can only support %d processes and not the %d requested\n", + num_workers, NUMBER_WORKERS); + } + + /* generate a summary for the user */ + (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); + printf("default cpu mask: %s\n", cpumaskstr); + printf("default num worker processes: %i\n", num_workers); + + cpu = odp_cpumask_first(&cpu_mask); + printf("the first CPU: %i\n", cpu); + + /* reserve cpu 0 for the control plane so remove it from + * the default mask */ + odp_cpumask_clr(&cpu_mask, 0); + num_workers = odp_cpumask_count(&cpu_mask); + (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); + printf("new cpu mask: %s\n", cpumaskstr); + printf("new num worker processes: %i\n\n", num_workers); + + memset(&thr_params, 0, sizeof(thr_params)); + thr_params.thr_type = ODP_THREAD_WORKER; + thr_params.instance = instance; + + /* Fork worker processes */ + ret = odph_linux_process_fork_n(proc, &cpu_mask, &thr_params); + + if (ret < 0) { + ODPH_ERR("Fork workers failed %i\n", ret); + return -1; + } + + if (ret == 0) { + /* Child process */ + worker_fn(NULL); + } else { + /* Parent process */ + odph_linux_process_wait_n(proc, num_workers); + + if (odp_term_global(instance)) { + ODPH_ERR("Error: ODP global term failed.\n"); + exit(EXIT_FAILURE); + } + } + + return 0; +} diff --git a/helper/test/linux/pthread.c b/helper/test/linux/pthread.c new file mode 100644 index 0000000..2bec0d1 --- /dev/null +++ b/helper/test/linux/pthread.c @@ -0,0 +1,87 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +#define NUMBER_WORKERS 16 +static void *worker_fn(void *arg ODPH_UNUSED) +{ + /* depend on the odp helper to call odp_init_local */ + + printf("Worker thread on CPU %d\n", odp_cpu_id()); + + /* depend on the odp helper to call odp_term_local */ + + return NULL; +} + +/* Create additional dataplane threads */ +int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) +{ + odph_linux_pthread_t thread_tbl[NUMBER_WORKERS]; + odp_cpumask_t cpu_mask; + int num_workers; + int cpu; + char cpumaskstr[ODP_CPUMASK_STR_SIZE]; + odp_instance_t instance; + odph_linux_thr_params_t thr_params; + + if (odp_init_global(&instance, NULL, NULL)) { + ODPH_ERR("Error: ODP global init failed.\n"); + exit(EXIT_FAILURE); + } + + if (odp_init_local(instance, ODP_THREAD_CONTROL)) { + ODPH_ERR("Error: ODP local init failed.\n"); + exit(EXIT_FAILURE); + } + + /* discover how many threads this system can support */ + num_workers = odp_cpumask_default_worker(&cpu_mask, NUMBER_WORKERS); + if (num_workers < NUMBER_WORKERS) { + printf("System can only support %d threads and not the %d requested\n", + num_workers, NUMBER_WORKERS); + } + + /* generate a summary for the user */ + (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); + printf("default cpu mask: %s\n", cpumaskstr); + printf("default num worker threads: %i\n", num_workers); + + cpu = odp_cpumask_first(&cpu_mask); + printf("the first CPU: %i\n", cpu); + + /* reserve cpu 0 for the control plane so remove it from + * the default mask */ + odp_cpumask_clr(&cpu_mask, 0); + num_workers = odp_cpumask_count(&cpu_mask); + (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); + printf("new cpu mask: %s\n", cpumaskstr); + printf("new num worker threads: %i\n\n", num_workers); + + memset(&thr_params, 0, sizeof(thr_params)); + thr_params.start = worker_fn; + thr_params.arg = NULL; + thr_params.thr_type = ODP_THREAD_WORKER; + thr_params.instance = instance; + + odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, &thr_params); + odph_linux_pthread_join(thread_tbl, num_workers); + + if (odp_term_local()) { + ODPH_ERR("Error: ODP local term failed.\n"); + exit(EXIT_FAILURE); + } + + if (odp_term_global(instance)) { + ODPH_ERR("Error: ODP global term failed.\n"); + exit(EXIT_FAILURE); + } + + return 0; +} diff --git a/test/Makefile.inc b/test/Makefile.inc index 243a616..1ad5d3a 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -4,7 +4,7 @@ LIB = $(top_builddir)/lib #in the following line, the libs using the symbols should come before #the libs containing them! The includer is given a chance to add things #before libodp by setting PRE_LDADD before the inclusion. -LDADD = $(PRE_LDADD) $(LIB)/libodphelper-@with_helper_platform@.la $(LIB)/libodp-linux.la +LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp-linux.la INCFLAGS = \ -I$(top_builddir)/platform/@with_platform@/include \ diff --git a/test/common_plat/validation/api/Makefile.inc b/test/common_plat/validation/api/Makefile.inc index a0afd26..dda18ad 100644 --- a/test/common_plat/validation/api/Makefile.inc +++ b/test/common_plat/validation/api/Makefile.inc @@ -13,4 +13,4 @@ AM_LDFLAGS += -static LIBCUNIT_COMMON = $(COMMON_DIR)/libcunit_common.la LIBCPUMASK_COMMON = $(COMMON_DIR)/libcpumask_common.la LIBTHRMASK_COMMON = $(COMMON_DIR)/libthrmask_common.la -LIBODP = $(LIB)/libodphelper-@with_helper_platform@.la $(LIB)/libodp-linux.la +LIBODP = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la diff --git a/test/linux-generic/Makefile.inc b/test/linux-generic/Makefile.inc index 2a49076..4b88b43 100644 --- a/test/linux-generic/Makefile.inc +++ b/test/linux-generic/Makefile.inc @@ -6,7 +6,7 @@ AM_LDFLAGS += -static LIBCUNIT_COMMON = $(top_builddir)/test/common_plat/common/libcunit_common.la LIB = $(top_builddir)/lib -LIBODP = $(LIB)/libodphelper-@with_helper_platform@.la $(LIB)/libodp-linux.la +LIBODP = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la INCCUNIT_COMMON = -I$(top_srcdir)/test/common_plat/common INCODP = \